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 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!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.