Question how to insert values in database using table adapter?

akshay_honey

New member
Joined
Feb 25, 2010
Messages
3
Programming Experience
Beginner
i want to use the data adapter for standard login and registration procedures.

my first form is a login window contaning 2 textboxes,one for username and one for password.. i used a table adapter to connect to database.. using sql statement.in the adapter
"SELECT COUNT(*) AS Result, username AS usernameinput, [password] AS passwordinput
FROM users
GROUP BY username, [password]
HAVING (username = ?) AND ([password] = ?) AND (COUNT(*) = 1)"


my form has the following code where ValidateUserNamePassword is the function name

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim r = Me.UsersTableAdapter1.ValidateUserNamePassword(Me.TextBox1.Text, Me.TextBox2.Text)
If r Is Nothing Then
MsgBox("fail")
Else
MsgBox("pass")
Me.Visible = False
Form2.Visible = True
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class


now my problem is i want to add data in the same database which is used for login purpose.
i use the insertquery function but the data does not update in the database.

my registration page code is

Public Class Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.UsersTableAdapter.Insert(TextBox1.Text, TextBox2.Text, Label2.Text)

End Sub

Dim a As Integer

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim qa = UsersTableAdapter.ScalarQuery1()
Label2.Text = qa

End Sub
End Class

i would like to know wht am i missing..
 
here is the basic idea..what i have done.. its in visual studio 2005
 

Attachments

  • app.zip
    42.7 KB · Views: 47
Last edited by a moderator:
Back
Top