【发布时间】:2015-12-19 21:37:12
【问题描述】:
我的代码抛出了主题中提到的这个错误。我不知道起源,因为使用 ODBC 连接到 mysql 它可以工作,但是使用 SQL 连接到 SQL Server Express 是行不通的。如何解决?
SqlCommand Command = new SqlCommand("insert into lojas (NIF, Loja, bloqueado, DataFim, lastupdate, Nome) values (?, ?, ?, ?, ?, ?)", connection);
Command.CommandType = CommandType.Text;
Command.Parameters.AddWithValue("@NIF", grid_lic.CurrentRow.Cells[1].Value);
Command.Parameters.AddWithValue("@Loja", grid_lic.CurrentRow.Cells[2].Value);
Command.Parameters.AddWithValue("@Bloqueado", grid_lic.CurrentRow.Cells[3].Value);
Command.Parameters.AddWithValue("@DataFim", grid_lic.CurrentRow.Cells[4].Value);
Command.Parameters.AddWithValue("@lastupdate", grid_lic.CurrentRow.Cells[5].Value);
Command.Parameters.AddWithValue("@Nome", grid_lic.CurrentRow.Cells[6].Value);
connection.Open();
Command.ExecuteNonQuery();
【问题讨论】:
标签: sql sql-server odbc sqlcommand