| |

VerySource

 Forgot password?
 Register
Search
View: 596|Reply: 2

Problems modifying data in SQL tables

[Copy link]

4

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 Germany

Post time: 2020-1-26 22:40:01
| Show all posts |Read mode
Partial Class upuser
    Inherits System.Web.UI.Page
    Dim sqlcon As New SqlConnection
    Dim myCommand As New SqlCommand


    Private Sub Page_Load (ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim student_id As String = Request.Cookies ("userInf"). Values ​​("userID")
        Dim con As New SqlConnection ("server = .; database = user; uid = lgw; password = lgw")
        Dim cmd As New SqlCommand ("select * from users where id = '"&Request.Cookies ("userInf"). Values ​​("userID")&"'", con)
        Dim dr As SqlDataReader
        con.Open ()
        dr = cmd.ExecuteReader

        dr.Read ()
        showid.Text = dr.Item ("id")
        showName.Text = dr.Item ("name")
        showTel.Text = dr.Item ("tel"). ToString
        showEmail.Text = dr.Item ("email"). ToString
        showIntro.Text = dr.Item ("intro"). ToString
        con.Close ()

        If DateTime.Now.Hour> = 6 And DateTime.Now.Hour <12 Then
            spWelMessage.Text = "Good morning, login ID is ("&student_id&")"
        ElseIf DateTime.Now.Hour> = 12 And DateTime.Now.Hour <18 Then
            spWelMessage.Text = "Good afternoon, login ID is ("&student_id&")"
        Else
            spWelMessage.Text = "Good evening, login ID is ("&student_id&")"
        End If
    End Sub



    Protected Sub reset_Click (ByVal sender As Object, ByVal e As System.EventArgs) Handles Reset.Click
        showPWD.Text = ""
        textpwd.Text = ""
        showName.Text = ""
        showTel.Text = ""
        showEmail.Text = ""
        showIntro.Text = ""
    End Sub


Protected Sub Enter_Click (ByVal sender As Object, ByVal e As System.EventArgs) Handles Enter.Click

        Dim myCommand As New SqlCommand
        Dim sqld2 As String
        Dim ds As New Data.DataSet
        sqlcon = New SqlConnection ("server = .; database = user; uid = lgw; password = lgw")
        sqlcon.Open ()
        'myCommand.Connection = sqlcon
        sqld2 = "update users set intro = '"&showIntro.Text&"' where id = '"&showid.Text&"'"
        myCommand = New SqlCommand (sqld2, sqlcon)
        myCommand.ExecuteNonQuery ()
        sqlcon.Close ()

    End Sub
End Class

The last is to modify the data in the users table in the database. When I run, there are no errors, but the information in the database has not changed. Is there something wrong? ? ?
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-2-18 23:15:01
| Show all posts
Add if not Page.IsPostBack Then to page_load code

Dim student_id As String = Request.Cookies ("userInf"). Values ​​("userID")
...


End IF
Reply

Use magic Report

0

Threads

12

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-3-7 14:30:02
| Show all posts
Check if showid.Text does have a value?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list