How to retrieve data from sql server db to form controls?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rasha Farouk
    New Member
    • Oct 2008
    • 11

    How to retrieve data from sql server db to form controls?

    Peace upon u all
    I wanna know how to retrieve data from db and pass it to form controls.
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    Heres an example using adodb
    Code:
    <%
    Dim strCon
    Dim strSQL
    Dim rs
    Dim dbHost, dbName, dbUsername, dbPassword
    dbHost="Localhost"
    dbName="Test"
    dbUsername="Test"
    dbPassword="Test"
    strCon="Provider=SQLOLEDB;SERVER=" &  dbHost & ";DATABASE=" & dbName & ";UID=" & dbUsername & ";PWD=" & dbPassword
    set cn = server.CreateObject("adodb.connection")
    set rs = server.CreateObject("adodb.recordset")
    cn.Open strCon
    
    strSQL="select * from whatever"
    rs.open strSQL, cn, 1, 1
    if not rs.eof then
    %>
    <input type="text" name="whatever" value="<%=rs("whatever")%>">
    <%
    end if
    rs.close
    cn.close
    set rs = nothing
    set cn = nothing
    %>

    Comment

    • Rasha Farouk
      New Member
      • Oct 2008
      • 11

      #3
      Thanks for help but I work with asp.net .

      Originally posted by iam_clint
      Heres an example using adodb
      Code:
      <%
      Dim strCon
      Dim strSQL
      Dim rs
      Dim dbHost, dbName, dbUsername, dbPassword
      dbHost="Localhost"
      dbName="Test"
      dbUsername="Test"
      dbPassword="Test"
      strCon="Provider=SQLOLEDB;SERVER=" &  dbHost & ";DATABASE=" & dbName & ";UID=" & dbUsername & ";PWD=" & dbPassword
      set cn = server.CreateObject("adodb.connection")
      set rs = server.CreateObject("adodb.recordset")
      cn.Open strCon
      
      strSQL="select * from whatever"
      rs.open strSQL, cn, 1, 1
      if not rs.eof then
      %>
      <input type="text" name="whatever" value="<%=rs("whatever")%>">
      <%
      end if
      rs.close
      cn.close
      set rs = nothing
      set cn = nothing
      %>

      Comment

      • iam_clint
        Recognized Expert Top Contributor
        • Jul 2006
        • 1207

        #4
        Moved your thread to the .net section

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Hey!

          Please take a look at your other thread. I gave a whole bunch of links pointing you in the right direction there and was waiting for you to tell me more about what you've tried and what problems you're facing.

          Please do Not double post your questions in the future.

          Comment

          Working...