Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Trying to Add a Database using VB.net


draginvoke5
 Share

Recommended Posts

So I fixed the other problem because of another member named Ryo, and after I got some sleep I fixed it and then I did a little tweaking and now I got this error: No value given for one or more required parameters. And its a OleDbException error. and this is the code for Login:

```

Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Tammie\AppData\Local\Microsoft\VisualStudio\11.0\Databases\userDB.accdb"

Dim myConnection As OleDbConnection = New OleDbConnection

Dim da As OleDbDataAdapter

Dim strSQL As String

Dim ds As DataSet

Dim firstName As String

Dim userName As String

strSQL = "SELECT tblUsers.firstName FROM tblUsers "

strSQL = strSQL & "WHERE (tblUsers.userName = '" & (Me.TextBox1.Text) & "' "

strSQL = strSQL & "And tblUsers.userPassword = '" & (Me.TextBox2.Text) & "'"

strSQL = strSQL & "And tblUsers.Email = '" & (Me.TextBox3.Text) & "' );"

myConnection.ConnectionString = connString

da = New OleDbDataAdapter(strSQL, myConnection)

ds = New DataSet

da.Fill(ds, "users")

myConnection.Close()

For Each rowTest In ds.Tables(0).Rows

firstName = rowTest("FirstName").ToString

Next

If userName <> "" Then

MessageBox.Show("Welcome " & userName & "!")

Else

MessageBox.Show("Please check Username and Password.")

End If

```

And this line is highlighted:

```

da.Fill(ds, "users")

```

Not sure if this is needed but here is the code for registration:

```

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim strSQL As String

Dim objCmd As New OleDbCommand

strSQL = "INSERT INTO tblUsers(userName, userPassword, Email) "

strSQL = strSQL & "VALUES('" & (Me.TextBox1.Text) & "', '" & (Me.TextBox2.Text) & "','" & (Me.TextBox3.Text) & "');"

Dim Con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Tammie\AppData\Local\Microsoft\VisualStudio\11.0\Databases\userDB.accdb")

Con.Open()

objCmd = New OleDbCommand(strSQL, Con)

objCmd.ExecuteNonQuery()

Con.Close()

MessageBox.Show("You have successfully registered. Please login.")

Form1.Show()

Me.Hide()

End Sub

```

Thanks in advance for your help ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...