connect to access database
-
I want to retrieve the name of the database from a text box (datasource = txtdatabase.text), but the connection does not work. the connection is made with the direct assignment of name database directly cnx = new OleDbConnection ("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D: \ \ mabase.mdb");
class Connexion { static public OleDbConnection cnx; static bool ok; static public Boolean getConnexion() { if (cnx == null) { cnx = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+datasource); try { cnx.Open(); ok = true; } catch (OleDbException) { ok = false; } } return ok; } }
-
I want to retrieve the name of the database from a text box (datasource = txtdatabase.text), but the connection does not work. the connection is made with the direct assignment of name database directly cnx = new OleDbConnection ("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D: \ \ mabase.mdb");
class Connexion { static public OleDbConnection cnx; static bool ok; static public Boolean getConnexion() { if (cnx == null) { cnx = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+datasource); try { cnx.Open(); ok = true; } catch (OleDbException) { ok = false; } } return ok; } }
MemberDotNetting wrote:
the connection does not work.
And you know that it does not work because....?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
-
MemberDotNetting wrote:
the connection does not work.
And you know that it does not work because....?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
sorry?
-
sorry?
He means "How do you know it doesn't work? Do you get an exception? If so, what is the message?" Your original question is vague, and not answerable. You need to provide better information.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
I want to retrieve the name of the database from a text box (datasource = txtdatabase.text), but the connection does not work. the connection is made with the direct assignment of name database directly cnx = new OleDbConnection ("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D: \ \ mabase.mdb");
class Connexion { static public OleDbConnection cnx; static bool ok; static public Boolean getConnexion() { if (cnx == null) { cnx = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+datasource); try { cnx.Open(); ok = true; } catch (OleDbException) { ok = false; } } return ok; } }
catch (OleDbException)
{
ok = false;
}What is the point of catching an exception if you then throw it away?
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
-
catch (OleDbException)
{
ok = false;
}What is the point of catching an exception if you then throw it away?
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
In fact I have another idea that will start with this idea, in fact I have a WPF application, following the click on the button I want to select the name of the database via an open file dialog and display the name source in textebox, the method returns a message box to display the exception, but I used the bool type because my class is linked to a library and I can't use the message box
-
In fact I have another idea that will start with this idea, in fact I have a WPF application, following the click on the button I want to select the name of the database via an open file dialog and display the name source in textebox, the method returns a message box to display the exception, but I used the bool type because my class is linked to a library and I can't use the message box
So have you heard of
Debug.WriteLine()
?? Wihtout the exception messages, it's pretty much impossible to tell you what's wrong with any accuracy.A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
sorry?
No where did you say what errors you was getting or any exceptions. "It does not work" is not at all helpful in any way in describing your problem. How do you know it doesn't work? Did you get an error? Did you get an exception? Did your harddrive melt? We can't see your database or read your mind.
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
-
catch (OleDbException)
{
ok = false;
}What is the point of catching an exception if you then throw it away?
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness