Hey. I am working on a project in SQL Server & VB.NET. On the web form there is a single line textbox and a mutli-line textbox. When you click the button it’s supposed to update a entry in the SQL Database. But when I try using this code it won’t work, or it will but it will be all strange??!??!
VB Code:
  1. Dim strRedirect As String
  2.         strRedirect = Request("uid")
  3.         Dim tempstringa As String = TextBox1.Text
  4.         Dim tempstringb As String = TextBox2.Text
  5.         Dim cmd As SqlCommand
  6.         Dim cnn As SqlConnection
  7.         cnn = New SqlConnection("server=localhost;user=dex2;pwd=password1;database=pocketdotnet;")
  8.         Dim tempstringc As String = "UPDATE " & Me.Session.Item("workgroup") & "News set title='%%%%', disc='%%%%%' where uid='" & strRedirect & "'"
  9.         tempstringc = Replace(tempstringc, "'%%%%'", "'" + Server.HtmlEncode(tempstringa) + "'")
  10.         tempstringc = Replace(tempstringc, "'%%%%%'", "'" + Server.HtmlEncode(tempstringb) + "'")
  11.         cmd = New SqlCommand(Server.HtmlEncode(tempstringc), cnn)
  12.         cnn.Open()
  13.         cmd.ExecuteNonQuery()
  14.         cnn.Close()