Hi there, just started to use .net. Thing is i can view data from the database which is really good, but i cant add, the code must be wrong somewhere, i dont know why, could someone have a look and tell me if they can spot anything.
Public OpenConnection As OleDbConnection
Public DataAdapter As OleDbDataAdapter
Public DataCommand As OleDbCommand
Public Sub Connect()
Dim DBStr As String
Dim DBStr2 As String
DBStr = GetSetting ("Login", "DBSettings", "DBString"
DBStr2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Trim(DBStr) & ";Persist Security Info=False"
OpenConnection = New OleDbConnection(DBStr2)
OpenConnection.Open()
End Sub
Public Sub InsertUser(ByRef Username As String, ByRef Password As String, ByRef Firstname As String, ByRef Surname As String, ByRef Notes As String, ByRef AccessLevel As String, ByRef ForcePassword As String, ByRef LastPasswordChange As String, ByRef Enabled As Boolean, ByRef Deleted As Boolean)
Dim SQLStr As String
Call Connect()
SQLStr = "INSERT INTO Users VALUES('" & Trim(Username) & "','" & Trim(Password) & "','" & Trim(Firstname) & "','" & Trim(Surname) & "','" & Trim(Notes) & "','" & Trim(AccessLevel) & "','" & Trim(ForcePassword) & "','" & Trim(LastPasswordChange) & "','" & Trim(Enabled) & "','" & Trim(Deleted) & "')"
MsgBox(SQLStr)
DataCommand = New OleDbCommand(Trim(SQLStr), OpenConnection)
DataCommand.ExecuteNonQuery()
Call Disconnect()
End Sub
Sorry the code is a bit long, maybe someone could point out the problem, well i hope so or you could tell me how i should be doing it.
Kind Regards
JP
Public OpenConnection As OleDbConnection
Public DataAdapter As OleDbDataAdapter
Public DataCommand As OleDbCommand
Public Sub Connect()
Dim DBStr As String
Dim DBStr2 As String
DBStr = GetSetting ("Login", "DBSettings", "DBString"
DBStr2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Trim(DBStr) & ";Persist Security Info=False"
OpenConnection = New OleDbConnection(DBStr2)
OpenConnection.Open()
End Sub
Public Sub InsertUser(ByRef Username As String, ByRef Password As String, ByRef Firstname As String, ByRef Surname As String, ByRef Notes As String, ByRef AccessLevel As String, ByRef ForcePassword As String, ByRef LastPasswordChange As String, ByRef Enabled As Boolean, ByRef Deleted As Boolean)
Dim SQLStr As String
Call Connect()
SQLStr = "INSERT INTO Users VALUES('" & Trim(Username) & "','" & Trim(Password) & "','" & Trim(Firstname) & "','" & Trim(Surname) & "','" & Trim(Notes) & "','" & Trim(AccessLevel) & "','" & Trim(ForcePassword) & "','" & Trim(LastPasswordChange) & "','" & Trim(Enabled) & "','" & Trim(Deleted) & "')"
MsgBox(SQLStr)
DataCommand = New OleDbCommand(Trim(SQLStr), OpenConnection)
DataCommand.ExecuteNonQuery()
Call Disconnect()
End Sub
Sorry the code is a bit long, maybe someone could point out the problem, well i hope so or you could tell me how i should be doing it.
Kind Regards
JP