[英]Error Data source name not found and no default driver specified with Odbc in ADO.NET
I'm having this error when i try to add some data from UI into MSSQL database and through all the questions&answers about this error i found, couldn't understand where the problem is. 当我尝试将UI中的一些数据添加到MSSQL数据库中并且通过关于所发现的关于此错误的所有问题和答案时,我遇到了此错误,无法理解问题出在哪里。 Could anyone give me some help?
谁能给我些帮助吗? Thanks.
谢谢。
OdbcConnection conexiune = new OdbcConnection("Data Source=CODRINMA\\codrinma;Initial Catalog=BD;Integrated Security=True");
conexiune.Open();
OdbcCommand cominsert = new OdbcCommand("insert into Tabela(idX,denumire,adresa,idY) values(?,?,?,?)", conexiune);
cominsert.Parameters.Clear();
cominsert.Parameters.AddWithValue("@idX", int.Parse(txtID.Text.Trim()));
cominsert.Parameters.AddWithValue("@denumire", char.ToUpper(txtDenumire.Text.Trim()[0]) + txtDenumire.Text.Trim().Substring(1));
cominsert.Parameters.AddWithValue("@adresa", char.ToUpper(txtAdresa.Text.Trim()[0]) + txtAdresa.Text.Trim().Substring(1));
cominsert.Parameters.AddWithValue("@idY", int.Parse(cmbCamp.SelectedValue.ToString()));
cominsert.ExecuteNonQuery();
MessageBox.Show("Message!!");
conexiune.Close();
this.Dispose();
"An unhandled exception of type 'System.Data.Odbc.OdbcException' occurred in System.Data.dll
“ System.Data.dll中发生了'System.Data.Odbc.OdbcException类型的未处理的异常
Additional information: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
其他信息:错误[IM002] [Microsoft] [ODBC驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序“
When using ODBC you need to include the driver to use in the connection string. 使用ODBC时,需要在连接字符串中包括要使用的驱动程序。
See OdbcConnection.ConnectionString
. 请参阅
OdbcConnection.ConnectionString
。
For instance if your server is SQL Server then add 例如,如果您的服务器是SQL Server,则添加
driver={SQL Server}
to the connection string. 连接字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.