Using results from a sql query in a variable RRS feed

  • Question

  • User-826584469 posted

    Hey guys.

    I've managed to use my MS Access database with repeaters and gridviews in my website. Basically, printing the result of a query directly to the website seems easy enough using something like this :

    <%@ Page Language="VB" debug="true" %>
    <%@ Import Namespace="System.Data.OleDb" %>
    <script runat="server">
    Sub sql_query()
    dim myQuery as string = "SELECT * FROM awesomeness"
    dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("awesomedb.mdb"))
    dbcomm = New OleDbCommand(myQuery, dbconn)
    dbread = dbcomm.ExecuteReader()
    someRepeater.datasource = dbread
    End Sub
    <form id="Form1" runat="server">
    <asp:repeater id="someRepeater" runat="server>

    After quite a bit of googling this seems to be a common way to do this.

    My question then seems kinda silly.

    I want to use some of the data from the query in for example a variable without sending the data to a repeater or gridview and so on. Say I just want the username and a password from a database and want to store the username in one variable and the password in another for further use in the code. What do I do?

    Saturday, October 2, 2010 6:03 PM