AFterlife Posted March 21, 2005 Posted March 21, 2005 (edited) Ok. This is my first time working with SQL Server. I was under the impression that using a SQL Connection that you dont need a provider for it. But i get this error. An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;'. So why does it do that. Dim da As OleDb.OleDbDataAdapter Dim oSQLConn As SqlConnection = New SqlConnection oSQLConn.ConnectionString = "Data Source=(local);" & _ "Initial Catalog=dbCustomers;" & _ "Integrated Security=SSPI" Dim myCustomer As New CCustomer With myCustomer .FirstName = txtFirstName.Text .LastName = txtLastName.Text .City = txtCity.Text .ZipCode = txtZipCode.Text .Country = txtCountry.Text End With Dim SQL As String = "INSERT INTO dbCustomers.tblCustomers (CustomerID, FirstName, LastName, Address, City, ZipCode, Country) VALUES (" _ & "'" & myCustomer.FirstName & "'" & " ," & "'" & myCustomer.LastName & "'" & " ," & "'" _ & myCustomer.Address & "'" & " ," & "'" & myCustomer.City & "'" & " ," & "'" & myCustomer.ZipCode & "'" & " ," & "'" & myCustomer.Country & "'" & ")" da = New OleDb.OleDbDataAdapter(SQL, oSQLConn.ConnectionString) Oops.. I think Im ok.. I forgot about the command object and executing non query's. Edited March 21, 2005 by AFterlife Quote
Administrators PlausiblyDamp Posted March 21, 2005 Administrators Posted March 21, 2005 If you are dealing with SQL use the System.Data.SqlClient.SqlConnection object rather than an OleDBConnection object. The OleDb version will always require a provider the SqlClient version can only be used with SQL and therefore doesn't need a provider. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
IxiRancid Posted March 25, 2005 Posted March 25, 2005 I believe that you call OleDbDataAdapter with SqlConnection, also make sure as PlausiblyDamp said, import only System.Data.SqlClient. SUM: stick to one provider ;) Quote
AFterlife Posted March 25, 2005 Author Posted March 25, 2005 That was an accident in my post.Thats not in my code. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.