oledb

Multiple Insert statements in one connection

。_饼干妹妹 提交于 2019-12-02 11:44:59
问题 I need some tips on how to do this better, I am inserting multiple queries with using one connection. I understand this is not good programming , especially with it being very prone to sql injection, I also wanted to mention it's not going to be out on the internet just run locally. This is what I have so far.. public partial class Modify : System.Web.UI.Page { OleDbConnection connection; OleDbCommand command; public void OpenConnection2() { connection = new OleDbConnection(""); command = new

How to import data from one column of Excel to listbox using C#

独自空忆成欢 提交于 2019-12-02 11:13:00
I have an openFileDialog tool. I will choose a excel file from my computer and my programme read a column (for example A column) and write my listbox on GUI. How can i do it via OleDB? I am new at C#. If you explain detailed, I will be happy for that. Thank you for your help. In order to use the OLEDB provider successfully we have to consider a few points. The OLEDB provider for Excel 2003 files is different from the one used for Excel 2007/2010 files. So, the first thing we have to do is determining the Excel file format in order to select the correct provider. In the code example below I

Syntax error in INSERT INTO Statement when writing to Access

断了今生、忘了曾经 提交于 2019-12-02 10:24:51
I am trying to write a program where I can write data to an Access DB but I keep getting the error “Syntax error in INSERT INTO statement”. FirstLast is the name of the table; First and Last are columns in it. Imports System.Data.OleDb Public Class Form1 Dim theConnectionString As New OleDbConnection Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click theConnectionString.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\Database1.accdb" Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO

“Parameter ?_1 has no default value” error when ExecuteReader

▼魔方 西西 提交于 2019-12-02 10:14:28
Having problem with the code below in a web service. Have searched for a solution but nothing that I have seen seems different to what I am doing below. NB: The string variable 'AccountNo' is a passed into a function which includes the code below. The error is generated on the last line of code - ExecuteReader. Dim sConnString As String Dim rdr As OleDbDataReader Dim orderPaid As Decimal Dim fbeused As Decimal sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='c:\orders.mdb'" Dim conn As New OleDbConnection(sConnString) Dim sb As New StringBuilder sb.Append("SELECT DISTINCTROW

How to query a remote MS ACCESS .mdb database using C#

偶尔善良 提交于 2019-12-02 10:04:56
I am trying to use C# to query a mote MS ACCESS database .mdb file. I can successfully query it when copying the file to my local machine. I just want to put the file remotely, so my the client side program doesn't contain raw data. static string m_path = "http://www.xyz.com/temp/"; static string m_connWords = "Provider=Microsoft.JET.OLEDB.4.0;data source = " + m_path + "data.mdb"; I skip the rest of code doing connection, reader, and query. I am sure when I have my m_path change to a local path for a local mdb copy, it works. And I can download the mdb file when using the url path, so the url

I get “Syntax error in UPDATE statement” with OleDB

六月ゝ 毕业季﹏ 提交于 2019-12-02 10:02:30
I am developing an information system that works with a connected data source / MS Access database. The question is kinda cliche but I can't seem to find a proper solution from the similar ones I have come across. Here is my code for the button. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'myConnection.ConnectionString = connString 'myConnection.Open() If Me.txtConfirmPasscode.Text = Me.txtNewPasscode.Text Then Dim updateCmd As OleDbCommand = New OleDbCommand("UPDATE Users SET Password = @ConfPasscode WHERE [Usernames] = @UsersID"

Troubleshooting Could not find installable ISAM error

China☆狼群 提交于 2019-12-02 09:43:54
问题 I have 32-bit MS Office 2013 Installed, along with the 32-bit office redistributable and a small c# console application set to compile to 32-bit. The following code causes an OleDbException stating "Could not find installable ISAM." public void GetData() { var fileName = @"c:\temp\Sales DataBase_Test.accdb"; var connection = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Soure='" + fileName + "'"; using (var conn = new OleDbConnection(connection)) { conn.Open(); conn.Close(); } } Instead of

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

Missing column of Dates in CSV file using Schema.ini file

时光毁灭记忆、已成空白 提交于 2019-12-02 09:27:10
问题 Note: answering my own problem to help others in future. I'm reading a CSV file with OleDB: DataTable csvTableSchema = new DataTable(); //Open the CSV string csvFilePath = "C:\\temp\\WithDateColumn.csv"; var connString = string.Format( @"Provider=Microsoft.Jet.OleDb.4.0; Data Source={0};Extended Properties=""Text;HDR=YES;FMT=Delimited""", Path.GetDirectoryName(csvFilePath) ); //To read the csv with DataTypes we specify the columns and their datatypes in the Schema.ini //REF https://docs

Convert Null to zero in access database

微笑、不失礼 提交于 2019-12-02 09:17:54
问题 Considering that Grade.firstExam, Grade.secondExam, and Grade.finalExam are all TEXT and not numbers , i can't get the exact solution to convert null values into Zeros. I already tried to use NZ() but it returns an error message (Undefined Function 'NZ' in expression) im using VB.net with MS Access as my database. i also imported System.Data.OleDb Namespace. SQLStatement = " SELECT Student.idNumber as 'IDno', " SQLStatement &= " Student.lastName + ', ' + Student.firstName as 'FullName', "