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:
sub GetUser_EMail(byval user)
dim oConn, oRec, un
user = mid(user,7)
Session("user") = user
set oConn = Server.CreateObject("ADODB.Connection")
set oRec = Server.CreateObject("ADODB.Recordset")
oConn.ConnectionTimeout = 35
oConn.CommandTimeout = 30
oConn.Provider = "ADsDSOObject"
oConn.CursorLocation = 2
oConn.Properties("ADSI Flag") = 1
oConn.Properties("User ID") = "ltcom\myUser"
oConn.Properties("Password") = "myPassword"
oConn.Open ("Provider=ADsDSOObject;User Id=ltcom\myUser;Password=myPassword;" )
oRec.Open "<LDAP://srvad/DC=in,DC=telecom,DC=lt>;(&(ObjectClass=person)(samAccountName=" & user & "));cn,mail;subtree", oConn
if oRec.EOF then
else
un = oRec.Fields("cn").Value
Session("UserName") = un
if (instr(Application("usernames"),un)=0) then
Application.Lock
Application("usernames") = Application("usernames") & un & ";"
Application.UnLock
end if
Session("email") = "" & oRec.Fields("mail").Value
end if
if (oRec.State <> 0) then
oRec.Close
end if
oConn.Close
set oRec = nothing
set oConn = nothing
Session("mail_bcc") = Session("email")
else
Session("mail_bcc") = ""
end if
end sub
I think in VB .NET it would be something different?
Thanks in advance