I am making a simple login form using winforms and accessing a 2010 database (.accdb) in C #.
I have the following code and it seems that the connection string is incorrect. I tried to find and found that .Jet to access 07 ?? but this does not seem to work. I am an amateur in databases (code from msdn). I am having trouble understanding what I should use for this example.
access table name: haha
ID (PK) | password
-----------------------
1 | testing
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\BC207\test.accdb"); System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(); comm.CommandText = "SELECT HAHA(*) FROM password"; comm.CommandType = CommandType.Text; comm.Connection = conn; conn.Open(); Object returnValue = comm.ExecuteScalar(); conn.Close(); MessageBox.Show((string)returnValue);
edited: the table name is the password, and the field I want to get is the identifier.
The SQL statement I wrote it as: SELECT ID FROM password
and yes, only one entry in only one field in the table as a primary key.
In any case, the problem is that the program freezes when executed on the first line
-> Keyword not supported: 'provider'.
so I realized that I have the wrong connection string.
source share