Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database Connection with Visual Basic 2005

Status
Not open for further replies.

RaceStats

IS-IT--Management
Nov 10, 2006
15
0
0
US
I'm converting a program from VB6 to VB 2005 and am having problems trying to figure out the connection and updating the database. In VB6 my code looked pretty much like this:

Code:
Set objCon = New ADODB.Connection
Set objCom = New ADODB.Command
    
'Creating the DB connection string
objCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=WorkOrders.mdb;Persist Security Info=False"
    
'Opening the connection
objCon.Open objCon.ConnectionString
Set objRSPendingWorkOrders = New ADODB.Recordset
objRSPendingWorkOrders.Open "tblPendingWorkOrders", objCon, adOpenStatic, adLockOptimistic

    With objRSPendingWorkOrders
        .AddNew
        .Fields("Environment") = dtacmbEnvironment.BoundColumn
        .Fields("ServerType") = dtacmbServerType.Text
        .Fields("RequestorName") = txtRequestorName
        .Fields("ContactNo") = txtContactNo
        .Fields("ProjectNo") = txtProjectNo
        .Fields("ProjectName") = txtProjectName
        .Fields("WorkGroup") = cboWorkGroup
        .Fields("SWFDate") = txtSWFDate
        .Fields("InstallIssuances") = txtInstallIssuances
        .Fields("BackoutIssuances") = txtBackoutIssuances
        .Fields("NoonRequest") = optNoon.Value
        .Fields("ContactAlias") = txtRequestorAlias
        .Fields("CCAlias1") = txtCCAlias1
        .Fields("CCAlias2") = txtCCAlias2
        .Fields("CCAlias3") = txtCCAlias3
        .Fields("CCAlias4") = txtCCAlias4
        .Fields("CCAlias5") = txtCCAlias5
        .Fields("Servers") = sServers
        .Update
    End With

Most of my research results have turned up information geared towards SQL or I just don't seem to understand what they are getting at.

I know this is a simple soluton and I would appreciate a little help in the right direction.

Thanks
 
You could try:
Code:
'Creating the DB connection string
DBFile = "C:\Docs\WorkOrders.mdb"
    
'Opening the connection
objCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & DBFile & ";"

There is a VB.Net forum that may be useful to you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top