Results 1 to 2 of 2

Thread: MS SQL (Sub from classic VB)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2000
    Location
    Europe, Lithuania
    Posts
    309

    MS SQL (Sub from classic VB)

    Hey, how to connect to MS SQL server and retrieve some data?

    In classic vb I had sub:

    VB Code:
    1. sub GetUser_EMail(byval user)
    2.     dim oConn, oRec, un
    3.        
    4.     user = mid(user,7)
    5.     Session("user") = user
    6.    
    7.     set oConn = Server.CreateObject("ADODB.Connection")
    8.     set oRec = Server.CreateObject("ADODB.Recordset")
    9.    
    10.     oConn.ConnectionTimeout = 35
    11.     oConn.CommandTimeout = 30
    12.     oConn.Provider = "ADsDSOObject"
    13.     oConn.CursorLocation = 2
    14.     oConn.Properties("ADSI Flag") = 1
    15.     oConn.Properties("User ID") = "ltcom\myUser"
    16.     oConn.Properties("Password") = "myPassword"
    17.     oConn.Open ("Provider=ADsDSOObject;User Id=ltcom\myUser;Password=myPassword;" )
    18.     oRec.Open "<LDAP://srvad/DC=in,DC=telecom,DC=lt>;(&(ObjectClass=person)(samAccountName=" & user & "));cn,mail;subtree", oConn
    19.     if oRec.EOF then
    20.         Session("email") = "[email protected]"
    21.     else
    22.         un = oRec.Fields("cn").Value
    23.         Session("UserName") = un
    24.         if (instr(Application("usernames"),un)=0) then
    25.             Application.Lock
    26.             Application("usernames") = Application("usernames") & un & ";"
    27.             Application.UnLock
    28.         end if
    29.         Session("email") = "" & oRec.Fields("mail").Value  
    30.     end if 
    31.     if (oRec.State <> 0) then
    32.         oRec.Close
    33.     end if
    34.     oConn.Close
    35.     set oRec = nothing
    36.     set oConn = nothing
    37.     if (Session("email")<>"[email protected]") then
    38.         Session("mail_bcc") = Session("email")
    39.     else
    40.         Session("mail_bcc") = ""
    41.     end if
    42. end sub

    I think in VB .NET it would be something different?

    Thanks in advance

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

Posting Permissions

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



Click Here to Expand Forum to Full Width