clebo99
asked on
Inputing Into SQL DB from Visual 2003 App
I'm a VB 6.0 programmer that is used to using commands such as the ones shown below. I'm trying to take baby steps so all I want to do now is create a simple form and enter the information into a single table within a SQL DB located on my laptop. Are there any easy tutorials or examples I can cheat off of to learn how to do this?
Const provider As String = "Provider=SQLOLEDB;Data Source=servername;Initial Catalog=tablename;Integrat ed Security=SSPI;"
Public cn As ADODB.Connection
Dim variablename As New ADODB.Recordset
Public Sub opendatabase()
On Error GoTo error
Set cn = New ADODB.Connection
cn.ConnectionString = provider
cn.Open
Exit Sub
error:
Dim errloop, errcol
Set errcol = cn.Errors
MsgBox provider
For Each errloop In errcol
MsgBox errloop.Description & vbCrLf
Next
End Sub
Const provider As String = "Provider=SQLOLEDB;Data Source=servername;Initial Catalog=tablename;Integrat
Public cn As ADODB.Connection
Dim variablename As New ADODB.Recordset
Public Sub opendatabase()
On Error GoTo error
Set cn = New ADODB.Connection
cn.ConnectionString = provider
cn.Open
Exit Sub
error:
Dim errloop, errcol
Set errcol = cn.Errors
MsgBox provider
For Each errloop In errcol
MsgBox errloop.Description & vbCrLf
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The error I seem to be getting in VB 2003 is with the variable declaration of the ADODB connection. It doesn't seem to understand that.
The way I learn (fortunately or unfortunately) is to see a simple example and then run with it. I am really hoping that it is as easy (maybe easy isn't the right word. How about "the same") as in VB 6.0 where I can declare my DB connections, write a simple "OPEN DB" Procedure and perform simplified INSERT/UPDATE queries to the DB.
Does anyone have a quick "cheat sheet" on what the initial "setup" in the code would be for this?
Chris