0

hi frnds,
i was a get a problem,
i want to update the serialnumber by using a text box,,,,
suppose i am updating the serial number as 3,,,,it was updated,,,,
but if i wants to update the serial number as 4 ,that is already in the database it is also updated..but actually it is not updated..but it is updated.........
pls give me the code here iam using asp.net with vb.net
database is sql server
here my code is given below,,,,,,,,

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click

        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("guest1").ConnectionString())
        Dim adp As SqlDataAdapter
        Dim ds As New DataSet
        Dim SQL As String = "update guesthouse set booking_no ='" + TextBox4.Text + "' where booking_no='" + TextBox3.Text + "'"
        conn.Open()
        Dim com As New SqlCommand(SQL, conn)
        Dim dr As SqlDataReader
        dr = com.ExecuteReader()
        Label2.Text = " Room Is Changed"

    End Sub
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by reach_yousuf
0

hi frnds,
i was a get a problem,
i want to update the serialnumber by using a text box,,,,
suppose i am updating the serial number as 3,,,,it was updated,,,,
but if i wants to update the serial number as 4 ,that is already in the database it is also updated..but actually it is not updated..but it is updated.........
pls give me the code here iam using asp.net with vb.net
database is sql server
here my code is given below,,,,,,,,

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click

        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("guest1").ConnectionString())
        Dim adp As SqlDataAdapter
        Dim ds As New DataSet
        Dim SQL As String = "update guesthouse set booking_no ='" + TextBox4.Text + "' where booking_no='" + TextBox3.Text + "'"
        conn.Open()
        Dim com As New SqlCommand(SQL, conn)
        Dim dr As SqlDataReader
        dr = com.ExecuteReader()
        Label2.Text = " Room Is Changed"

    End Sub

Hi kanuri1
change your code at

dr = com.ExecuteReader()

and replace it by

com.ExecuteNonQuery()

pls.check if it works!!!
reader is used for datareader not for insert/update operations!!!

Edited by reach_yousuf: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.