Hi Friends,
I am using Asp.net 2005. I post my code in below. While i executed this code it will not work (not update properly). Please look into this and help me where i am in wrong.
Imports System.Data
Imports System.IO
Imports System.Data.SqlClient
Partial Class changepassword
Inherits System.Web.UI.Page
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim adp As SqlDataAdapter
Dim ds As DataSet
Dim reader As SqlDataReader
<pre lang="vb">Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click</pre>
<pre lang="vb">cmd = New SqlCommand("<b>select * from ureg where uname = '" & TextBox1.Text & "' and upass = '" & TextBox2.Text & "'", con</b>)
Dim reader As SqlDataReader
reader = cmd.ExecuteReader()
If reader.Read() = True Then
cmd = New SqlCommand("<b>update ureg SET uname = " & TextBox1.Text & ", upass = " & TextBox3.Text & " , cpass = " & TextBox4.Text & " where uname = ' " & TextBox1.Text & " ' ", con</b>)
cmd.ExecuteNonQuery()
Response.Write("changed")
Else
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End If
reader.Close()
con.Close()</pre>
End Sub
<pre lang="vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
con = New SqlConnection("Data Source=gopi;database=Hospital;Integrated Security=True")
con.Open()
End Sub
End Class</pre>
Thanks and Regards,
Gopi A