943,754 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 5074
  • ASP.NET RSS
Oct 5th, 2008
0

displaying data from database to textbox

Expand Post »
Hello everyone,

I am working on a web using ASP.Net (VB) and Sybase as its back end. I am trying to display data from database to the textbox. Does anyone know, pls help.

Here's my code and its not working. pls. pls help. thanks a lot

Try
conn.Open()
cmd = New AseCommand("select Name from employee where Id = 12", conn)
reader = cmd.ExecuteReader()

If reader.Item("Name") = txtUserName.Text Then
txtPwd.Text = reader.Item("Name")
Else
txtPwd.Text = "No Match Data"
End If

Catch ex As AseException

Finally
If Not (reader Is Nothing) AndAlso Not (reader.IsClosed) Then
reader.Close()
End If
If Not (cmd Is Nothing) Then
cmd.Dispose()
End If
If Not (conn Is Nothing) Then ' AndAlso (conn.State <> ConnectionState.Closed) Then
conn.Close()
End If
End Try


I am not familiar with ASP.net. If you can modify especially in this part

If reader.Item("Name") = txtUserName.Text Then
txtPwd.Text = reader.Item("Name")
Else
txtPwd.Text = "No Match Data"
End If
it would be a great help. I know the error is in this part but I don't know what keyword or function i am going to use. Thanks a lot
Last edited by dudegio; Oct 5th, 2008 at 8:29 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dudegio is offline Offline
66 posts
since May 2007
Oct 5th, 2008
0

Re: displaying data from database to textbox

Hey Guys,

At last i found an unsolved article that uses the .Read function in reading data from database.
Below is my solution.

conn.Open()

cmd = New AseCommand("select * from employee where Id = " & txtUserName.Text, conn)
reader = cmd.ExecuteReader()
reader.Read()

If reader("Id") = txtUserName.Text Then
txtPwd.Text = reader("Name")
End If
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dudegio is offline Offline
66 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Newbie Having Trouble
Next Thread in ASP.NET Forum Timeline: gridview+javascript





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC