I have used the following to get data from my SQL database and populate text
& label boxes.
I understand how to use parameters with gridview and data view but not with
the reader.
How can I change this code to use parameters and so give some protection
from insertion issues.
Dim con As New
SqlConnection(C onfigurationMan ager.Connection Strings("mydata ConnectionStrin g").ToString )
Dim str As String
Dim sel As SqlCommand
Dim myReader As SqlDataReader
con.Open()
str = "Select id, title, keywords, speaker, date_text, duration
from webcasts where id=" & Val(Request.Que ryString("id")) and speaker=" &
"'" & textbox_speaker _requested.text &"'"
sel = New SqlCommand(str, con) : myReader = sel.ExecuteRead er()
If myReader.Read() Then
If (myReader.IsDBN ull(0)) = False Then Label_id.Text =
myReader.GetInt 32(0)
If (myReader.IsDBN ull(1)) = False Then TextBox_title.T ext =
myReader.GetStr ing(1).Trim
If (myReader.IsDBN ull(2)) = False Then TextBox_keyword s.Text
= myReader.GetStr ing(2).Trim
If (myReader.IsDBN ull(3)) = False Then TextBox_speaker s.Text
= myReader.GetStr ing(3).Trim
If (myReader.IsDBN ull(4)) = False Then
TextBox_daterec orded.Text = myReader.GetStr ing(4).Trim
If (myReader.IsDBN ull(5)) = False Then TextBox_duratio n.Text
= myReader.GetInt 32(5)
End If
myReader.Close( ) : con.Close()
netnatter
Comment