|
-
Sep 24th, 2008, 06:06 PM
#1
Thread Starter
Hyperactive Member
[URGENT] OledbCommand Parameters Not Working - HELP!
vb Code:
Public Function CreateDatabase(ByVal DBDirectory As String) As Boolean
With frmNewEditCourse
Dim DB As New ADOX.Catalog()
Try
DB.Create(Connection.ConnectionString)
SQL = "CREATE TABLE [Information] ([CIndex] AutoIncrement, [CourseCode] TEXT, [RoomNumber] TEXT, [SchoolYear] TEXT, [Teacher] Text)"
Command = New OleDbCommand(SQL, Connection)
Command.Connection.Open()
Command.ExecuteNonQuery()
Command.CommandText = "INSERT INTO [Information] (CourseCode, RoomNumber, SchoolYear, Teacher) VALUES(@CourseCode, @RoomNumber, @SchoolYear, @Teacher)"
Command.Parameters.AddWithValue("@CourseCode", .txtCourseCode.Text)
Command.Parameters.AddWithValue("@RoomNumber", .txtRoomNumber.Text)
Command.Parameters.AddWithValue("@SchoolYear", .txtSchoolYear.Text)
Command.Parameters.AddWithValue("@Teacher", .txtTeacher.Text)
Command.Connection.Close()
MsgBox("Done")
Catch Excep As System.Runtime.InteropServices.COMException
Finally
DB = Nothing
End Try
End With
End Function
Theirs my Function, what it does is it creates a Database and then its suppose to write the values into the database. Its creating it, but its just not inserting the values into the Table. Why?
Edit:
No Errors Occur and the MsgBox does show up.
Last edited by Wesley008; Sep 24th, 2008 at 06:56 PM.
-
Sep 24th, 2008, 07:12 PM
#2
Lively Member
Re: [URGENT] OledbCommand Parameters Not Working - HELP!
Wesley008,
You are never executing the Insert command.
After you have added all the parameters and before you close the connection:
Command.ExecuteNonQuery()
Kerry Moorman
-
Sep 24th, 2008, 07:26 PM
#3
Thread Starter
Hyperactive Member
Re: [URGENT] OledbCommand Parameters Not Working - HELP!
Wow. Thank You. I'm kinda getting new to the Parameters so I thought I didn't need to Execute
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|