Need help -- new to SQL server

Results 1 to 2 of 2

Thread: Need help -- new to SQL server

  1. #1
    KPW Guest

    Default Need help -- new to SQL server

    I can do Access stuff, but I&#039m very new to working with SQL server.<BR><BR>Can somebody tell my why, when I run this code, I get an error that "The operation requested by the application is not allowed if the object is closed".<BR><BR>&#060;%<BR>Dim objConn<BR>Dim sSql<BR>Dim rs<BR>Dim sUserName<BR>Dim sPassword<BR>Dim sConnect<BR><BR>sConnect = "Driver={SQL Server}; Server=MYSERVER; Database=MYDB; UID=USERNAME; PWD=PASSWORD"<BR>sUserName = "something"<BR>sPassword = "stuff"<BR><BR>set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .Open sConnect<BR>sSql = "procVerifyNTLogin " & sUserName & ", " & sPassword<BR>Set rs = objConn.Execute(sSql)<BR><BR>Do while not rs.eof<BR> Response.Write rs.Fields("0")<BR> Response.Write rs.Fields("1")<BR> Response.Write rs.Fields("2")<BR> rs.MoveNext<BR>Loop<BR><BR>set rs = Nothing<BR>set objConn = Nothing<BR>%&#062;<BR><BR>This code is almost verbatim from an article on 4Guys.<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Need help -- new to SQL server

    one thing you could do to ease your pain is to use a DSN like this:<BR><BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .Open "DSN=yourDSNname; UID=Your_user_name; PWD=your_password"<BR><BR>Then create your Record Set:<BR>strSQL = "SELECT * FROM table_name"<BR><BR> &#039Create the Record Source and open it<BR> Set objProdRS = Server.CreateObject("ADODB.Recordset")<BR> objProdRS.Open strSQL, objConn<BR><BR>Once I have this I start testing to make sure tha tthe record set was filled like this<BR><BR>strTest = objProdRS("field_name")<BR><BR>Response.Write Len(strTest) & "<BR>" & strTest<BR><BR>This way if the rs is empty I know because the length is zero.<BR><BR>hope this helps

Posting Permissions

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