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!!!!


Recommended Answers

All 4 Replies

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

sql = "Select * from SRuser where Uname = '" & name & "'"
commented: Good help many thanks!!! +0

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!!

Ur welcome....
Do visit again in case of any issues or for helping others....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.