0% found this document useful (0 votes)
28 views2 pages

Ole DB

Conexón oledb

Uploaded by

damahashr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views2 pages

Ole DB

Conexón oledb

Uploaded by

damahashr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

OleDb

[Visual Basic]
Dim nwindConn As OleDbConnection = New
OleDbConnection("Provider=SQLOLEDB;Data Source=localhost;" & _
"Integrated Security=SSPI;Initial
Catalog=northwind")
Dim custDA As OleDbDataAdapter = New OleDbDataAdapter
Dim selectCMD AS OleDbCommand = New OleDbCommand(selectSQL, nwindConn)
custDA.SelectCommand = selectCMD
' Add parameters and set values.
selectCMD.Parameters.Add("@Country", OleDbType.VarChar, 15).Value = "UK"
selectCMD.Parameters.Add("@City", OleDbType.VarChar, 15).Value = "London"
Dim custDS As DataSet = New DataSet
custDA.Fill(custDS, "Customers")

OleDb u Odbc
[Visual Basic]
Dim selectSQL As String = "SELECT CustomerID, CompanyName FROM Customers
WHERE Country = ? AND City = ?"
Dim insertSQL AS String = "INSERT INTO Customers (CustomerID, CompanyName)
VALUES (?, ?)"
Dim updateSQL AS String = "UPDATE Customers SET CustomerID = ?,
CompanyName = ? WHERE CustomerID = ?"
Dim deleteSQL As String = "DELETE FROM Customers WHERE CustomerID = ?"

Odbc
[Visual Basic]
Dim nwindConn As OdbcConnection = New OdbcConnection("Driver={SQL
Server};Server=localhost;" & _
"Trusted_Connection=yes;Database=northwind")
Dim custDA As OdbcDataAdapter = New OdbcDataAdapter
Dim selectCMD AS OdbcCommand = New OdbcCommand(selectSQL, nwindConn)
custDA.SelectCommand = selectCMD
' Add Parameters and set values.
selectCMD.Parameters.Add("@Country", OdbcType.VarChar, 15).Value = "UK"
selectCMD.Parameters.Add("@City", OdbcType.VarChar, 15).Value = "London"

Dim custDS As DataSet = New DataSet


custDA.Fill(custDS, "Customers")

Dim objBuilder As New SqlCommandBuilder(objSqlAdapter)


objSqlAdapter.UpdateCommand = objBuilder.GetUpdateCommand
Try
objSqlAdapter.Update(objDataSet, "tblTickets")
'Dim int As Integer = 10
'Dim intZ As Integer = 0
'Dim intT As Double = int / intZ
'objDataSet.AcceptChanges()
Catch dbConError As DBConcurrencyException
createMessage(dbConError)
Catch dataException As DataException
MessageBox.Show(dataException.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
Catch e As SystemException
MessageBox.Show(e.Message)
End Try

You might also like