Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all,

Does anyone know if this is wrong somewhere?

My form closes without any exception/warning!!!

           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

Posted

The ConnectionString variable perhaps? :D Well it's gonna be a blind guess with this little information.

 

Or maybe your application didn't go through your code? :D

Amir Syafrudin
Posted

Connection strings

 

Helpful as always... :rolleyes:

 

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

 

I noticed both here and in your other thread, Delete From Group, that you're 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 :)

Never trouble another for what you can do for yourself.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...