469,315 Members | 1,570 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

ADODB.Connection in an ASP Page VBScript subroutine

18
I am working on creating a new ASP page that needs to populate a Select object after three other fields have been populated. I am calling a VBScript subroutine to do this from the OnClick for the specified Select object. The problem I am having is that the code will not create the ADODB Connection. I know the username and password work and if I were to create the connection in the main body of loading the page it would connect. From everything I have read and found on the internet I should be able to do this via the subroutine but can not figure out why it is not working. Any help on this would be creately appreciated.

Expand|Select|Wrap|Line Numbers
  1. Sub LoadPoList(FieldNo,strConnect)
  2.  
  3.     Do until frmAddInvoice("cmbConsPO" & FieldNo).length = 0
  4.         frmAddInvoice("cmbConsPO" & FieldNo).remove 0
  5.     loop
  6.  
  7.     Max = FieldNo + 5
  8.     value = FieldNo
  9.  
  10.     strConn  = "Driver={SQL Server}; Server=" & MyServer  & ";Database=" & MyDB  & "; Uid=" & MyUserName & ";"
  11.     strConn = strConn &  " Pwd=" & MyPassWord & ";"
  12.     Set myConn = Server.CreateObject("ADODB.Connection")
  13.     myConn.Open strConn
  14.  
  15.     UseOwner = Trim(document.frmAddInvoice.cmbOwner.value)
  16.     UseDestination = Trim(document.frmAddInvoice.cmbDestination.value)
  17.     UsePart = Trim(document.all("txtGTW" & FieldNo).Value)
  18.     strSQL = "SELECT DISTINCT ReferenceID FROM InventoryTransactions WHERE (TransactionType = 'Shipment') AND (Invoice IS NULL) AND (Destination = '" & UseDestination & "') AND (COID = " & UseOwner & ") AND (PartNumber = '" & UsePart & "')"
  19.     set rds =  conn.execute(strSQL, dbOpenDynaset)
  20.     Do While not rds.eof
  21.     AddToDropDown(FieldNo,"")
  22.     Do While Not rds.eof
  23.         AddToDropDown(FieldNo,ReferenceID)
  24.         rds.movenext
  25.     loop
  26.     rds.close
  27.     set rds = nothing
  28.     set myConn = nothing
  29. End Sub
  30.  
Sep 7 '07 #1
3 3612
jhardman
3,406 Expert 2GB
so it's giving you an error at the setMyconn line? Everything looks good to me there. Try writing out the strConn variable to see if it looks right.

Jared
Sep 10 '07 #2
Heggr
18
Yes I have tried doing that and it does look correct.

I have talked with a co-worker and he seems to think it is because the manipulation of recordsets has to be done on the server side and NOT the client side. Do you know if this is correct? If this is correct do you know if it is possible to create the recordset on the server and then pass back the whole recordset as a variable back to the client side so it can be manipulated?
Sep 10 '07 #3
jhardman
3,406 Expert 2GB
Yes I have tried doing that and it does look correct.

I have talked with a co-worker and he seems to think it is because the manipulation of recordsets has to be done on the server side and NOT the client side. Do you know if this is correct? If this is correct do you know if it is possible to create the recordset on the server and then pass back the whole recordset as a variable back to the client side so it can be manipulated?
Ah, yes. I thought you were using this server-side. All ASP scripts run exclusively on the server and trying to get them to work on the client will fail in one way or another.

Probably the easiest way to do this nowadays is to open the whole recordset and export it as an XML file which can be manipulated ad nauseum by different components and even browsers. It's hard for me to know what you might want to manipulate on the client-side, since I am used to doing all my manipulations on the server, but this is doable. Let me know if this points you in the right direction.

Jared
Sep 10 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Steven Baeten | last post: by
reply views Thread by ASP.Confused | last post: by
3 posts views Thread by Joe Befumo | last post: by
9 posts views Thread by fniles | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.