1 Replies - 9560 Views - Last Post: 22 November 2010 - 01:27 AM Rate Topic: -----

#1 pentium  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-November 10

connecting vb6 to sql server 2005

Posted 21 November 2010 - 10:42 PM

After starting my first programming in vb2005 express edition and an sql server 2005 and not sql express, I'm unable to connect it to the DB hence have decided to try VB6 to sqlserver 2005 but still can't connect. My module code for connection in vb6 is
Public adoConn As New ADODB.Connection
    Public adoCmd As ADODB.Command
    Public strConn As String
    Public adoRst As ADODB.Recordset

    Public Function ConnDB()
        adoConn = New ADODB.Connection
        strConn = "Data Source=localhost; Provider=SQLOLEDB.1;Initial Catalog=HRMS;Integrated Security=SSPI;"


        With adoConn
            .Mode = ADODB.ConnectModeEnum.adModeShareDenyNone
            .CursorLocation = ADODB.CursorLocationEnum.adUseClient

            .ConnectionString = strConn
            ''.show()
        End With

        ' adoCmd = New ADODB.Command
        'adoCmd.ActiveConnection = adoConn
        'adoCmd.CommandType = adCmdText
    End Function



My form1 save command code for testing connection is as below;

Private Sub cmdSave_Click()
''Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
        Call ConnDB
        
        adoConn.Execute ("Insert into dbo.testy (firstname,address,status,phone,location) values ('" & txtfname.Text & "','" & txtaddress.Text & "','" & cbostatus.Text & "','" & txtlocation.Text & "','" & txtphone.Text & "')")
        MsgBox ("Details Saved")
     '' End ConnDB()
     '' frm1.Show()

    End Sub


Please assist and advice between VB6 and vb2005 express which I should go for????

Edited by macosxnerd101: Please use code tags, like so: :code:. Also, please avoid using excessive whitespace.

Is This A Good Question/Topic? 0
  • +

Replies To: connecting vb6 to sql server 2005

#2 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: connecting vb6 to sql server 2005

Posted 22 November 2010 - 01:27 AM

You could go for either VB6 or VB2005, both will connect to SQL Server 2005.

Try looking through the tutorial HERE
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1