ADO DOT NET Posted March 12, 2007 Posted March 12, 2007 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 Quote
Administrators PlausiblyDamp Posted March 12, 2007 Administrators Posted March 12, 2007 If you step through this in the debugger is there a particular line that causes the problem? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
amir100 Posted March 13, 2007 Posted March 13, 2007 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 Quote Amir Syafrudin
MrPaul Posted March 13, 2007 Posted March 13, 2007 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 :) Quote Never trouble another for what you can do for yourself.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.