oledbdatareader

Data type mismatch in criteria expression

断了今生、忘了曾经 提交于 2019-12-02 21:48:07
问题 myConnection.Open() rtb_Address.Clear() txt_Name.Clear() Dim str As String str = "SELECT * FROM table1 WHERE (cus_ID = '" & txt_ID.Text & "')" Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection) dr = cmd.ExecuteReader() While dr.Read() rtb_Address.Text = dr("cus_Addr").ToString txt_Name.Text = dr("cus_Name").ToString End While myConnection.Close() Error in dr = cmd.ExecuteReader() dr is declared as OleDbDataReader 回答1: cus_ID is probaly a numeric data type, but you try to query it

converting resultset from OleDbDataReader into list

二次信任 提交于 2019-12-02 19:02:41
问题 Consider a Winforms app connecting to a SQL Server 2008 database and running a SQL SELECT statement: string myConnectionString = "Provider=SQLOLEDB;Data Source=hermes;Initial Catalog=qcvaluestest;Integrated Security=SSPI;"; string mySelectQuery = "SELECT top 500 name, finalconc from qvalues where rowid between 0 and 25000;"; OleDbConnection myConnection = new OleDbConnection(myConnectionString); OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection); myCommand.Connection.Open(

Data type mismatch in criteria expression

大憨熊 提交于 2019-12-02 09:36:50
myConnection.Open() rtb_Address.Clear() txt_Name.Clear() Dim str As String str = "SELECT * FROM table1 WHERE (cus_ID = '" & txt_ID.Text & "')" Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection) dr = cmd.ExecuteReader() While dr.Read() rtb_Address.Text = dr("cus_Addr").ToString txt_Name.Text = dr("cus_Name").ToString End While myConnection.Close() Error in dr = cmd.ExecuteReader() dr is declared as OleDbDataReader cus_ID is probaly a numeric data type, but you try to query it with a string: (cus_ID = 'thevalue') . Just remove the enclosing ' : (cus_ID = thevalue) or better, use a

converting resultset from OleDbDataReader into list

徘徊边缘 提交于 2019-12-02 09:18:59
Consider a Winforms app connecting to a SQL Server 2008 database and running a SQL SELECT statement: string myConnectionString = "Provider=SQLOLEDB;Data Source=hermes;Initial Catalog=qcvaluestest;Integrated Security=SSPI;"; string mySelectQuery = "SELECT top 500 name, finalconc from qvalues where rowid between 0 and 25000;"; OleDbConnection myConnection = new OleDbConnection(myConnectionString); OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection); myCommand.Connection.Open(); OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); How can you

Why won't this DataAdapter insert rows into the database?

别等时光非礼了梦想. 提交于 2019-12-02 03:07:56
问题 So I have a situation where I am using a SqlDataAdapter to insert rows into a table in a SQL Server 2014 database. The source of the data is an Excel spreadsheet. The insert works fine when the DataTable object is populated using a few For loops and .Columns.Add and .Rows.Add to copy the data from the Excel sheet. This working code I have not included here. However, I am refactoring the code to use an OleDbDataReader. Here is my function: Private Function FillDataTable(path As String, name As

Why won't this DataAdapter insert rows into the database?

限于喜欢 提交于 2019-12-02 01:16:45
So I have a situation where I am using a SqlDataAdapter to insert rows into a table in a SQL Server 2014 database. The source of the data is an Excel spreadsheet. The insert works fine when the DataTable object is populated using a few For loops and .Columns.Add and .Rows.Add to copy the data from the Excel sheet. This working code I have not included here. However, I am refactoring the code to use an OleDbDataReader. Here is my function: Private Function FillDataTable(path As String, name As String) As DataTable Dim fullpath As String = path Dim wsname As String = name Dim dt = New DataTable(

LIKE query on an Access database via C# always returns COUNT(*) of 0

不问归期 提交于 2019-12-01 11:19:19
Please look into following code: using (OleDbConnection openCon = new OleDbConnection(ConfigurationManager.AppSettings["AccessConnectioString"])) { openCon.Open(); string tc = string.Empty; string ttc = string.Empty; if (!string.IsNullOrEmpty(QSetId)) { tc = "select count(*) as [Count] from ABC where QSetId = @qSetId and TText like 'RT*'"; } else { tc = "select count(*) as [Count] from PQR where TText like 'RT*'"; } using (OleDbCommand qtc= new OleDbCommand(tc)) { qtc.Connection = openCon; if (!string.IsNullOrEmpty(QSetId)) qtc.Parameters.Add("@qSetId", OleDbType.VarChar).Value = QSetId;

An OLE DB Provider was not specified in the ConnectionString. 'Provider=SQLOLEDB;

做~自己de王妃 提交于 2019-11-29 14:42:12
i trying to run query using C#, i am getting the following problem An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB; my code string strConString = System.Configuration.ConfigurationManager.ConnectionStrings["WorkflowConnStr"].ConnectionString.ToString(); string sqlstr = "select * from table" OleDbConnection myConnection = new OleDbConnection(strConString); try {myConnection.Open();} catch (Exception err) { System.Diagnostics.Debug.WriteLine(err.Message); } OleDbCommand myCommand = new OleDbCommand(sqlstr, myConnection); OleDbDataReader

How dump database table to excel sheet?

爱⌒轻易说出口 提交于 2019-11-28 11:28:58
问题 I am getting data from my database and I want to have that data as a table in excel file. So, I have written the following : Dim sheetToPopulate As Excel.Worksheet = getSheet() Dim reader As OleDbDataReader Dim query As String = "SELECT * FROM dataTable" Dim cmd As New OleDbCommand(query, oleConn) Dim reader As OleDbDataReader oleConn.Open() reader = cmd.ExecuteReader() Do While reader.Read() // How use the reader to populate the sheet at once. // I have the sheet object as sheetToPopulate. /

Access Database error:: “No value given for one or more required parameters.”

走远了吗. 提交于 2019-11-28 10:58:27
问题 I have a datagridview. In this DGV first colum is a combobox column. I want to make, when this combobox value is selected next fild will be filled automatically from database. But there shows a error. No value given for one or more required parameters on OleDbDataReader dr1 = cmd1.ExecuteReader(); I post the code. Please help me. OleDbConnection con = new OleDbConnection(conn); con.Open(); for (int i = 0; i < dgv.Rows.Count; i++) { string query = "select Description from General where AccCode