Kupoling-Katana
Member
- Joined
- Mar 13, 2006
- Messages
- 12
- Programming Experience
- Beginner
There's an error in my code, saying something about some INSERT INTO statement. Here's my code, give me whatever you can find out
locale = The location of the connection address, stored elsewhere.
Sorry there's not much help I can give you.
VB.NET:
Public Sub create_acc()
Try
Dim inc As Integer = 0
Dim maxrows As Integer
Dim con As New OleDb.OleDbConnection
Dim dataset As New DataSet
Dim newrow As DataRow
If locale <> String.Empty Then
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = " & locale
con.Open()
Dim sql As String = "SELECT * FROM accounts"
Dim adapter As OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter(sql, con)
adapter.Fill(dataset, "DB")
con.Close()
Dim builder As New OleDb.OleDbCommandBuilder(adapter)
newrow = dataset.Tables("DB").NewRow()
Dim username As String = wizard.username
Dim password As String = wizard.password
newrow.Item(0) = username
newrow.Item(1) = password
newrow.Item(2) = 1
dataset.Tables("DB").Rows.Add(newrow)
adapter.Update(dataset, "DB")
dbtry = 1
Else
MessageBox.Show("Please connect to the database first", "DB Error", 0, 16)
End If
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message, "Error", 0, 16)
dbtry = 0
Finally
If dbtry = 1 Then
wizard.bool = 1
MessageBox.Show("Account created!", "DB", 0, 64)
Else
MessageBox.Show("Account creation failed...", "DB Error", 0, 16)
End If
dbtry = 0
End Try
End Sub
locale = The location of the connection address, stored elsewhere.
Sorry there's not much help I can give you.