Groups > Databases > Access Databases and AccessDataSource Control > Re: how to Update database




how to Update database

how to Update database
Tue, 25 Mar 2008 11:23:36 +000
The follow code are add the new data( ID, Pasword) to database(Access) from the
Textbox items

Please to tech me to change or offer the code , some sample about update the
record like as:

Textbox1 is ID number,Textbox2 is new password, when people insert the ID number
and new password then click buttom, it will update the record

thank you~

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Server.MapPath("Account.mdb") & ";"

        Dim MySQL As String = "INSERT INTO member (ID, password) VALUES
('" & txtID.Text & "','" & txtpassword.Text &
"')"
        Dim MyConn As New Data.OleDb.OleDbConnection(strConn)
        Dim cmd As New Data.OleDb.OleDbCommand(MySQL, MyConn)
        MyConn.Open()
        cmd.ExecuteNonQuery()
        MyConn.Close()
Post Reply
Re: how to Update database
Tue, 25 Mar 2008 11:45:12 +000
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Server.MapPath("Account.mdb") & ";"
        Dim MySQL As String = "UPDATE member SET password = '" &
txtpassword.Text & "' WHERE ID = '" & txtID.Text &
"')"
        Dim MyConn As New Data.OleDb.OleDbConnection(strConn)
        Dim cmd As New Data.OleDb.OleDbCommand(MySQL, MyConn)
        MyConn.Open()
        cmd.ExecuteNonQuery()
        MyConn.Close() 

 

hope it helps./.
Post Reply
Re: how to Update database
Tue, 25 Mar 2008 14:47:10 +000
kaushalparik27:Dim MySQL As String = "UPDATE member SET password = '"
& txtpassword.Text & "' WHERE ID = '" & txtID.Text &
"')"

Please.  You should encourage newcomers to use parameters:
http://www.mikesdotnetting.com/Article.aspx?ArticleID=26
Post Reply
Re: how to Update database
Tue, 25 Mar 2008 14:56:35 +000
Mikesdotnetting:

kaushalparik27:Dim MySQL As String = "UPDATE member SET password = '"
& txtpassword.Text & "' WHERE ID = '" & txtID.Text &
"')"

Please.  You should encourage newcomers to use parameters:
http://www.mikesdotnetting.com/Article.aspx?ArticleID=26


 

yes, i agree. i think i should.. will take care in future.. thanx to point
out.
Post Reply
Re: how to Update database
Tue, 25 Mar 2008 15:28:45 +000
kaushalparik27:yes, i agree. i think i should
Post Reply
<< Previous 1 2 3 Next >>
( Page 1 of 3 )
about | contact