您好我仍然遇到此错误,我尝试了不同的解决方案,但它不起作用! 这是我的代码
我将连接字符串放在app.config文件中,如下所示:
<connectionStrings>
<add name="ComputerManagement"
connectionString= "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=.. ; Integrated Security=false"/>
并在表格的button_click中输入以下代码:
try
{
OleDbConnection conn = new OleDbConnection(GetConnectionString());
OleDbCommand command = new OleDbCommand();
command.CommandType = CommandType.Text;
command.CommandText = "INSERT INTO Clients(C_name,C_phone ,C_mob ,C_add , C_email ,C_account) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4 + "','" + textBox5.Text + "','" + textBox6.Text + "')";
command.Connection = conn;
conn.Open();
command.ExecuteNonQuery();
conn.Close();
}
catch (Exception) { throw; }
答案 0 :(得分:0)
您在声明中错过了.Text
textBox4
并且您还应该从连接对象构造命令,如:
OleDbCommand command = conn.CreateCommand();
你的代码命令中的对连接一无所知。