Hello All,
I have created a table in sql, and want to display a particular row, but only want to display the first 20 characters of it not the full message. How would u do this by using th data reader?
This is what i have done:
Dim cmd As SqlCommand = SqlConnection1.CreateCommand
cmd.Connection = SqlConnection1
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT * FROM Forum "
cmd.CommandText &= "WHERE receiver ='" & Session("Email") & "'"
Dim rowNumber As Int16
Response.Write("<BR>")
Response.Write("<b>Your Messages:</b>")
Response.Write("<Table border=1><tr><td>From</td><td>Message</td></tr>")
Dim dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.Default)
Do While dr.Read = True
Response.Write("<tr>")
Response.Write("<td>" & dr.Item("Sender") & "</td>")
Response.Write("<td>" & dr.Item("Message") & "</td>")
Response.Write("<td><a href='MessageReceive.aspx?read=" & dr.Item("Message") + "&sender=" & dr.Item("Sender") & "'>Read</a></td></tr>")
'
Loop
I thank you all you experts in advance.
I have created a table in sql, and want to display a particular row, but only want to display the first 20 characters of it not the full message. How would u do this by using th data reader?
This is what i have done:
Dim cmd As SqlCommand = SqlConnection1.CreateCommand
cmd.Connection = SqlConnection1
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT * FROM Forum "
cmd.CommandText &= "WHERE receiver ='" & Session("Email") & "'"
Dim rowNumber As Int16
Response.Write("<BR>")
Response.Write("<b>Your Messages:</b>")
Response.Write("<Table border=1><tr><td>From</td><td>Message</td></tr>")
Dim dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.Default)
Do While dr.Read = True
Response.Write("<tr>")
Response.Write("<td>" & dr.Item("Sender") & "</td>")
Response.Write("<td>" & dr.Item("Message") & "</td>")
Response.Write("<td><a href='MessageReceive.aspx?read=" & dr.Item("Message") + "&sender=" & dr.Item("Sender") & "'>Read</a></td></tr>")
'
Loop
I thank you all you experts in advance.