Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by AFterlife
  • Administrators
Posted
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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...