Thursday, March 22, 2012

textbox

Hi

Im trying to get data from sql server into a textbox. is it posible and if so how?

is there a tutorial i can read? i can get data into datagrids, datalists ,repeaters dropdown lists
but just cant figure out how to get it into a text or labelHi,

Use DataReader.Read(). See the sample below.


Function CheckUser(ByVal userid As String) As System.Data.SqlClient.SqlDataReader
Dim connectionString As String = "YourConnectionString"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT fname, lname, email FROM [clientuser] WHERE clientuser.userid = @.userid"

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)

sqlCommand.Parameters.Add("@.userid", System.Data.SqlDbType.Char).Value = userid

sqlConnection.Open()
Dim dtaReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Dim strFname As String
Dim strLname As String
Dim strEmail As String


While dtaReader.Read()
strFname = dtaReader("fname")
strLname = dtaReader("lname")
strEmail = dtaReader("email")

Response.Write(strFname )
End While

'Return dataReader
End Function


thank you

0 comments:

Post a Comment