Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem with vb ADO

    hey experts, need some help here
    the prob is this is my first time using visual basic and ADO so i got some errors in my codes which i can't work out
    i'm sending the code now and i hope u tell me what i did wrong
    __________________________________________________ ________
    Dim adoConn As ADODB.Connection
    Dim cmd As ADODB.Command
    Private Sub Adodc1_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

    End Sub

    Private Sub addUser_Click()
    Dim nou As Integer
    cmd = New ADODB.Command
    cmd.ActiveConnection = adoConn
    cmd.CommandType = adCmdStoredProc
    cmd.CommandText = "info"
    cmd.Parameters.Append cmd.CreateParameter("id", adInteger, adParamInput, Val(refId.Text))
    cmd.Parameters.Append cmd.CreateParameter("numOfUsers", adInteger, adParamOutput)
    cmd.Execute
    nou = cmd("numOfUsers")
    If (nou = 3) Then
    MsgBox "sorry,can't add more than 3 users under one referrer"
    End If

    End Sub

    Private Sub Form_Load()
    Dim constr As String
    adoConn = New ADODB.Connection
    adoConn.Provider = "SQLOLEDB.1"
    adoConn.ConnectionString = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=new;Data Source=np:MOHAMMED\SQLEXPRESS;Initial File Name=C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\nEw.mdf"
    adoConn.Open

    End Sub

  • #2
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Have you defined the variable "adCmdStoredProc"?

    cmd.CommandType expects an integer.
    My Website: DumpsterDoggy

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but adCmdStoredProc is a built in value

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Could you post what errors you are getting?
    OracleGuy

  • #5
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    I've had problems with this too. I've seen things where it is built in but I've found that implementation to be confusing. Have you tried just coding the value directly?

    Here is a link to the values
    My Website: DumpsterDoggy

  • #6
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok i'm getting an error on each line of this code:
    adoConn = New ADODB.Connection
    adoConn.Provider = "SQLOLEDB.1"
    adoConn.ConnectionString = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=new;Data Source=np:MOHAMMED\SQLEXPRESS;Initial File Name=C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\nEw.mdf"
    adoConn.Open

    //object variable or with block variable not set
    i put the declaration of adoConn in general declarations

    cmd.ActiveConnection = adoConn
    //object doesn't support method or property

  • #7
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    PremiumBlend:
    no actually i don know what values correspond to this property

  • #8
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    try doing:

    Code:
    set adoConn = New ADODB.Connection
    That might clear up the first error message.
    OracleGuy

  • #9
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i did that but i had new error
    Set adoConn.Provider="SQLOLEDB.1"
    //invalid use of property
    i knooow beginners are annoying

  • #10
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    On that liine get rid of the 'set'.
    OracleGuy

  • #11
    New Coder
    Join Date
    Aug 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank u sooo much this part worked and the connection came alive
    hoping there would be no errors in the other parts


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •