S
S
shutov_952019-06-25 22:04:27
C++ / C#
shutov_95, 2019-06-25 22:04:27

Why does System.Data.OleDb.OleDbException occur?

5d1271b02a637083812310.png
The essence of the problem: I do not want the "id" column to get from the database, so I try to replace * with "Criretia, Employee, Expert1, Expert2, Expert3" (although everything works fine with * and no error occurs).
But during the replacement, an error occurs from the title of the question.
System.Data.OleDb.OleDbException: "A value is missing for one or more required parameters."
Declaration "OleDbConnection conn = new OleDbConnection();" happens at the very beginning of "public partial class Form1 : Form"
Here is the code

conn.ConnectionString = @"provider = microsoft.ace.oledb.12.0; data source = |datadirectory|Database21.accdb";
            conn.Open();
            OleDbCommand com = new OleDbCommand();
            com.Connection = conn;
            com.CommandText = "SELECT Criretia, Employee, Expert1, Expert2, Expert3 FROM Table1";
            OleDbDataAdapter DA = new OleDbDataAdapter(com);
            DataTable DT = new DataTable();
            DA.Fill(DT); #ошибка указывает на эту строку
            dataGridView1.DataSource = DT;
            conn.Close();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FaNaT, 2019-06-26
@shutov_95

You have a wrong column in your query. On the screen "Criteria", and in the query "Criretia"
I advise you to execute queries in the DBMS, and from there copy it into the code. This will make it easier to find the error next time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question