Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27201

how do i update record in database

$
0
0
sir
this is my very early and new post and i am a beginner of knowledge in VB.net
my question is that how can i save new created data on the database
I am using visual studio.net ultimate and sqlserver express

the problem is
i cant update or create a new user account on the database while the data on the form is successfully saved in DataSets and SqlDataAdapter
following is the my code
i did not generate any error but also did not save user data on the database

Code:

' use  sql connection to make a new transaction into database
        Try
            SqlConUp1.Open()

            Dim dt As New DataTable
            'dt = DsSecretsUp1.Tables("Users", "Secrets")
            Dim newrow As DSSecretsUp.SecretsRow
            newrow = DsSecretsUp1.Secrets.NewSecretsRow
            newrow.Item("ID") = txtUserName.Text.Trim
            newrow.Item("Name") = txtUserName.Text.Trim
            newrow.Item("Address") = txtAddress.Text.Trim
            newrow.Item("Email") = txtEmail.Text.Trim
            newrow.Item("PhoneNo") = txtPhoneNo.Text.Trim
            newrow.Item("password") = txtpassword.Text.Trim
            DsSecretsUp1.Secrets.AddSecretsRow(newrow)

         

            If Not DsSecretsUp1.GetChanges(DataRowState.Added) Is Nothing Then
                SqlDAUp.Update(DsSecretsUp1.GetChanges(DataRowState.Added))
            End If


            MsgBox("Sign up completed, you can now log on to your account ", vbOKOnly, "Congratulation")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        ' show the login form and let user to logon to his account
        frmLogin.Show()
        frmLogin.txtloginuser.Text = txtUserName.Text
        Me.Close()

i place sqlDaUp (SQLDataAdapter) and DSSecrets(DataSet) on the form from the tools window after setting then
There are two tables in the database that need to be updated when a new user account created by user
USERS[ID,Name,Address,Gender,] , SECRETS[Password, PhoneNo]


please tell me why this code is not saving data on the database
or
kindly post ur code for updating database

Viewing all articles
Browse latest Browse all 27201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>