I am new to asp.net i have had some experience making windows in vb.net (VS2010)
I am trying to get my web to query a database then I want to display some of the returned data.

the code I have is..

Imports System.Data.OleDb

Partial Class Demos_Iain
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click

        Dim con As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection
        con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = ../SR.mdb"

        Dim sql As String

        Dim name As String = txtLogin.Text

        Dim password As String = txtPwd.Text

        sql = "Select * from SRuser where Uname =  " & name & " "

        Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
        dbCommand.CommandText = sql
        dbCommand.Connection = con

        Dim DA As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
        DA.SelectCommand = dbCommand

        Dim DS As System.Data.DataSet = New System.Data.DataSet


    End Sub
End Class

when i run the code it breaks at the DA.Fill(DS)

could anybody point out what I am doing wrong???

Thanks for any help!!!!


5 Years
Discussion Span
Last Post by poojavb

Just a guess...
ur select query does not have single inverted comma...

sql = "Select * from SRuser where Uname = '" & name & "'"
Votes + Comments
Good help many thanks!!!

ha i never even noticed that, thanks!!

how would i display selected data from the data set in say a text box?
it's not as easy as..
textbox1.text=DS(column name)

would i need to creat a data table then bind that to the data set then use textbox1.text = DataTable(column name)?

thanks again for your help!!!!!!


I have worked it out

lblError.Text = DS.Tables(0).Rows(0)("stampno").ToString

thanks for poining me in the right direction!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.