Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2002
    Posts
    6

    Angry Unanswered: how to connect from client to SQLserver

    hi group!

    i have problem with connection from client to sqlserver.

    and what must i do?

    thanks alot.

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Part from VB: open connection and call sp for update with parameters...

    May be it is a little complicated for novice...


    Dim MConnection As ADODB.Connection
    Dim MCommand As ADODB.Command
    Dim MRecordset As ADODB.Recordset
    Dim MParameter As ADODB.Parameter

    Set MConnection = CreateObject("ADODB.Connection")
    Set MCommand = CreateObject("ADODB.Command")

    LineConnect = "Provider=SQLOLEDB;Data Source=YourServer;UID=sa;PWD=sa"
    MConnection.ConnectionString = LineConnect
    MConnection.Open
    With MCommand
    .CommandText = "estore..UpdateLogin"
    .ActiveConnection = MConnection
    .CommandType = adCmdStoredProc
    .Parameters.Append MCommand.CreateParameter("RetVal", adInteger, adParamReturnValue)
    .Parameters.Append MCommand.CreateParameter("Id", adInteger, adParamInput, , 0)
    .Parameters.Append MCommand.CreateParameter("username", adLongVarChar, adParamInput, 20, UName)
    .Parameters.Append MCommand.CreateParameter("loginname", adLongVarChar, adParamInput, 128, LName)
    .Parameters.Append MCommand.CreateParameter("password", adLongVarChar, adParamInput, 128, LPass)
    .Parameters.Append MCommand.CreateParameter("usertypeid", adInteger, adParamInput, , UType)
    End With

    Set MRecordset = MCommand.Execute
    If MRecordset.EOF Or MRecordset.BOF Then
    ...........................

    another one:
    Dim MConnection As ADODB.Connection
    Dim MCommand As ADODB.Command
    Dim MRecordset As ADODB.Recordset

    Set MConnection = CreateObject("ADODB.Connection")
    Set MCommand = CreateObject("ADODB.Command")

    LineConnect = "Provider=SQLOLEDB;Data Source=ServerName;UID=sa;PWD="
    MConnection.ConnectionString = LineConnect
    MConnection.Open
    With MCommand
    .CommandText = "select .... or call SP"
    .ActiveConnection = MConnection
    .CommandType = adCmdText
    End With

    Set MRecordset = MCommand.Execute
    If MRecordset.EOF Or MRecordset.BOF Then
    ............................

Posting Permissions

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