I do understand. Having valid data in the database doesn't mean anything.
That's actually one of the worste ways to think when designing something
that queries the database as having data in the db is only a small part of
the battle. One of the things that happens often is the query that is sent
to the database is not exactly what you think it is. When this is the case,
it doesn't matter what data is in the database. Always try dumping your SQL
statement in testing before it is passed to the db to the browser or trace
through response.write() or trace.write(). This avoids a lot of unnecessary
tinkering sometimes as it's easy to keep working on the wrong things. In
this case, if you had dumped the sql string you would have noticed it wasn't
getting anything through the response.write when you clicked the button to
submit the userid because of the not page.ispostback condition
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"luna" <lu**@themoon.com> wrote in message
news:db******************@newsfep2-gui.server.ntli.net...
You seem to misunderstand
i checked the SQL server and I know that there is data in there -
definatley
im sure that the problem is something to do with
while objDR.Read()
surname1.text = objdr("surname1")
************************ <---- here never gets touched when code is
running end while
I have hardcoded the SQL statement at the moment so that it looks like
this:
Dim sql As String = "Select * from Personal where Personal.ID=2"
the thing that is annoying me is that the software seems to run perfectly
well, I dont get any error messages but it also doesnt
put anything into the textboxes or labels that i would like
any help that you could give me with this would be greatly appreciated
Mark.
"Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl... Have you made sure that you are actually getting results back? The While
objDR.Read() loop will only occur while the datareader is reading,
hence, if there is nothing to read then the textboxes will not be loaded. Where is the value for the userid.Text value coming from? Is it from a label? If it's
from a label that the user fills out, then presses a submit button to
load the data, then none of this will even happen because the IF statement is
making sure that the only time the code is executed is when the page
first loads. If this happens because of a user submitting then omit the Not in
the if statement because you want it to only occur when the page is posting
back. You also need to put something in there to make sure that there is
a valid userid in the textbox.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"luna" <lu**@themoon.com> wrote in message
news:Nh******************@newsfep2-gui.server.ntli.net... theres no errors in my code - but it does nothing at all - its
supposed to be populating text boxes!!
any ideas ? (im am pretty new to all this)
If Not Page.IsPostBack Then
Dim search As String
Dim strConn As String =
"server=Gringotts;uid=sa;pwd=password;database=dat abase"
Dim sql As String = "Select * from table where ID = " +
userid.Text.ToString
Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
Dim Cmd As New System.Data.SqlClient.SqlCommand(sql, conn)
Dim objDR As System.Data.sqlclient.SqlDataReader
conn.Open()
objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.Clos eConnection)
While objDR.Read()
'userid.Text = objDR("userid")
surname1.Text = objDR("surname1")
firstname1.Text = objDR("fname1")
Title1 = objDR("title1")
End While
Page.DataBind()
End If