Insert Into question

ADO DOT NET

Well-known member
Joined
Dec 20, 2006
Messages
156
Hi all,
Does anyone know if this is wrong somewhere?
My form closes without any exception/warning!!!
Code:
            Try
                Dim StringConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + My.Application.Info.DirectoryPath + "\AccessDB.mdb;Jet OLEDB:Database Password = mypass"
                Dim MyConnection As New OleDbConnection(StringConnection)
                MyConnection.Open()
                Dim CreateGroup As New OleDb.OleDbCommand("INSERT INTO Groups (GroupName) VALUES (" + GroupName.Text + ")", MyConnection)
                CreateGroup.ExecuteNonQuery()
                MyConnection.Close()
            Catch Ex As Exception
                MsgBox(Ex.Message.ToString)
            End Try
 
The ConnectionString variable perhaps? :D Well its gonna be a blind guess with this little information.

Or maybe your application didnt go through your code? :D
 
Connection strings

Helpful as always... :rolleyes:

Although not related to your question, I just thought Id raise another point.

I noticed both here and in your other thread, Delete From Group, that youre using hard-coded connection strings in each place that you connect to the database. While that might be maintainable with only 2 such methods, it is not a good approach in the long term. At the very least I would suggest you declare an application-scope variable (eg a Public Shared class field) for the connection string. Even better would be to use a configuration file and then access the string using ConfigurationManager.ConnectionStrings.

Good luck :)
 
Back
Top