Virginia Tech Hokie needs some serious HELP!

Hokie

New member
Joined
Apr 27, 2009
Messages
1
Programming Experience
Beginner
So I have a project due and I can't get my code to work. Can anyone help? In this form, I have a couple of textboxes that I need to insert data into my database.

Imports System.Data.OleDb

Public Class CreateAPlayer
Dim dynamicConnection As OleDbConnection
Dim dynamicCommand As OleDbCommand
Dim LoginDataAdapter As OleDbDataAdapter



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If FirstNameTextBox.Text = "" Then
MsgBox("First Name is required")
ElseIf LastNameTextBox.Text = "" Then
MsgBox("Last Name is required")
ElseIf MiddleInitialTextBox.Text = "" Then
MsgBox("Middle Initial is required")
ElseIf EmailUsernameTextBox.Text = "" Then
MsgBox("Email/Username is required")
ElseIf PasswordTextBox.Text = "" Then
MsgBox("Password is required")
Else
Me.Validate()

dynamicCommand.CommandText = "SELECT * FROM PlayerInfo WHERE FirstName='" & FirstNameTextBox.Text & "' AND LastName=" & LastNameTextBox.Text & "' AND MiddleInitial=" & MiddleInitialTextBox.Text & "' AND EmailUsername=" & EmailUsernameTextBox.Text & "' AND Password=" & PasswordTextBox.Text
Dim dynamicDataReader As OleDbDataReader = dynamicCommand.ExecuteReader()

dynamicCommand.CommandText = "INSERT INTO PlayerInfo(FirstName, LastName, MiddleInitial,EmailUsername, Password) VALUES('" & FirstNameTextBox.Text & "'," & LastNameTextBox.Text & "," & MiddleInitialTextBox.Text & "," & EmailUsernameTextBox.Text & ",'" & PasswordTextBox.Text & "')"
Dim dynamicRecords = dynamicCommand.ExecuteNonQuery()

End If

Catch
Me.Update()
Player_Login.Show()
End Try

End Sub
Private Sub CreateAPlayer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim dynamicConnection As New OleDbConnection( _
"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & Application.StartupPath & _
"\DynamicGolfScoringDatabase.accdb")

dynamicCommand = New OleDbCommand()

dynamicConnection.Open()

dynamicCommand.Connection = dynamicConnection
dynamicCommand.CommandText = ""


Dim dynamicDataReader As OleDbDataReader = dynamicCommand.ExecuteReader()

Catch
End Try
End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

End Sub

End Class
 
1. Please use CODE tags - it makes your code much easier to read.

2. Change your queries to parameterized - looking at your SQL, there are loads of bugs in it, which would all go away ;) Follow the link in my signature.
 
Back
Top