Results 1 to 2 of 2

Thread: Recordset

  1. #1
    Join Date
    Dec 1969

    Default Recordset

    when i need a data from sql by query where i should create a new recordset every time.<BR><BR>how to avoid the declaration of recordset everytime in asp page.

  2. #2
    Join Date
    Dec 1969

    Default RE: Recordset

    Try writing some functions in a seperate file. Include in that file and call the required function everytime u wanna use it.<BR><BR>eg.Dim cnn, rs, SQLStr<BR><BR>Function OpenDB()<BR> Set cnn = Server.CreateObject("ADODB.Connection")<BR> cnn.Open "DSN=OP" <BR> Set rs = Server.CreateObject("ADODB.Recordset")<BR>End Function<BR><BR>Function CloseDB()<BR> cnn.Close<BR> Set rs = Nothing<BR> Set cnn = Nothing<BR>End Function<BR><BR>Function SelectAllData(tmpvalues, tblname) <BR> SQLStr = "SELECT " & tmpvalues & " FROM " & tblname<BR> rs.Open SQLStr, cnn<BR>End Function<BR>.....<BR><BR>when u wanna select all data from a table called "Test"<BR>u just write<BR>Call OpenDB()<BR>Call SelectAllData("*","TEst")<BR>...code here<BR>Call CloseDB()<BR><BR>write the other function urself

Posting Permissions

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