A
A
Andrey Fomin2021-06-06 23:20:45
SQL
Andrey Fomin, 2021-06-06 23:20:45

Why did the error appear and how to fix it?

Hello!
There is this code in C#:

private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection sQLite = new SqlConnection("Data Source = LAPTOP-KJLU9H2F\\SQLEXPRESS; Integrated Security = True");
            sQLite.Open();
            string test = $"SELECT * FROM Автомобиль WHERE VIN_номер = '{VIN.Text}' AND Номер_заказа= '{Nomer_zakaza.Text}' AND Номер_филиала = '{Nomer_filiala.Text}'";
            SqlDataAdapter dataAdapter = new SqlDataAdapter(test, sQLite);
            DataSet ds = new DataSet();
            dataAdapter.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];
        }

And when the button is pressed, the
dataAdapter.Fill(ds);
following message appears on this line:
"Invalid object name 'Car'."

As I understand it, this is a cant in the sql query, but what exactly is the problem with the word Car is not clear to me.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Akina, 2021-06-07
@Akina

What exactly is the problem with the word Car is not clear to me.
Object names must match what is written about them in the documentation. And most likely it does NOT indicate that Cyrillic and other non-A characters are allowed.

A
Alexey Bereznikov, 2021-06-07
@gdt

You need to put the word Car in quotation marks, just like you did with columns.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question