problem when launching application
-
Firstly, tell us such things when you post a question - remember that we can't see your screen, access your HDD, or read your mind! :laugh: So - you open a connection, but you don't do anything else with it? either add:
cmd.Connection = connection;
Or use the syntax I showed in my previous answer. In the case of your code, I'd do this instead:
private void textBox1\_KeyUp(object sender, KeyEventArgs e) { DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("SELECT informix.thisent.etb FROM informix.thisent", connection); da.Fill(dt); dataGridView1.DataSource = dt; }
As the DataAdapter will open and close the connection for you. BTW: Please, don;t use Visual Studio default names for controls!
textBox1
doesn;t mean anything to anyone reading this code, where assearchForText
makes it much more obvious what you are doing. It's not a problem when your apps are tiny, but when the number of controls starts to rise it becomes a real PITA and can cause a lot of mistakes. It's well worth getting into the habit of changing the name immediately you create the control as (compared to the five or six seconds extra it takes) it can save a heck of a lot of time later!Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
Thank you for your interesting response . I do not have to eureur . I would change the names of the textbox I put a textbox to get the value in the db and display in the DataGridView . But when I run the application and I try to put a value in the text box the application starts to load and just stand . its starts to load but without result and it crashes :sigh: Thank you :)
-
Thank you for your interesting response . I do not have to eureur . I would change the names of the textbox I put a textbox to get the value in the db and display in the DataGridView . But when I run the application and I try to put a value in the text box the application starts to load and just stand . its starts to load but without result and it crashes :sigh: Thank you :)
Have you had a good look with the debugger?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
Have you had a good look with the debugger?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
there is no error , I think it's because he has too much data there.
-
there is no error , I think it's because he has too much data there.
So restrict the amount it is returning:
SELECT TOP 100 informix.thisent.etb FROM informix.thisent
would at least confirm that is the problem.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
-
I put :
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
connection.Open();
//Assignes la propriété Connection de ta SqlCommand à ta SqlConnection (connection) avant de l'ouvrir.SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "Select informix.thisent.etb from informix.thisent"; cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); dataGridView1.DataSource = dt; connection.Close();
Are you actually connecting to Informix here? If you are, I think you'll probably find that you are trying to use the SQL Server data classes to access them - hence the reason the connection doesn't open.
-
So restrict the amount it is returning:
SELECT TOP 100 informix.thisent.etb FROM informix.thisent
would at least confirm that is the problem.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
I have another error :( :( :( :( : An unhandled exception of type ' System.Data.Odbc.OdbcException ' occurred in System.Data.dll Additional Information : ERROR [ 42000 ] [ SCO Vision ] [ODBC Driver] SQL Server Retriever - Syntax error near '100
-
Are you actually connecting to Informix here? If you are, I think you'll probably find that you are trying to use the SQL Server data classes to access them - hence the reason the connection doesn't open.
I put another code :
private void Form1_Load(object sender, EventArgs e)
{
try
{
con = new OdbcConnection();
con.ConnectionString = @"Dsn=***;Driver={SCO Vision ODBC};uid=***;Pwd=****";
con.Open();
con);
adap = new OdbcDataAdapter("SELECT TOP 100 informix.thisent.etb FROM informix.thisent", con);
Ds = new System.Data.DataSet();
adap.Fill(Ds, "ibr");
dataGridView1.DataSource = Ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show("ERREUR\n" + ex.Message, "ERREUR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}BUT I have an error : error [42S22][SCO VISION][ODBC DRIVER][INFORMIX] column (top) not found in any table in the query .
-
I put another code :
private void Form1_Load(object sender, EventArgs e)
{
try
{
con = new OdbcConnection();
con.ConnectionString = @"Dsn=***;Driver={SCO Vision ODBC};uid=***;Pwd=****";
con.Open();
con);
adap = new OdbcDataAdapter("SELECT TOP 100 informix.thisent.etb FROM informix.thisent", con);
Ds = new System.Data.DataSet();
adap.Fill(Ds, "ibr");
dataGridView1.DataSource = Ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show("ERREUR\n" + ex.Message, "ERREUR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}BUT I have an error : error [42S22][SCO VISION][ODBC DRIVER][INFORMIX] column (top) not found in any table in the query .
That's because you are using illegal syntax in Informix. My Informix is a bit rusty, but I'm pretty sure you're meant to use
SELECT FIRST 100 ...
to get the data back.TOP
is a SQL Server keyword. -
That's because you are using illegal syntax in Informix. My Informix is a bit rusty, but I'm pretty sure you're meant to use
SELECT FIRST 100 ...
to get the data back.TOP
is a SQL Server keyword.It's good, I would give you a gift when you come in France ;P ;P ;P ;P ;P
-
hello : I am trying to develop an application in C # I made my connection string to connect to the database but when I launch an error message saying : An unhandled exception of type ' System.InvalidOperationException exception 'occurred in System.Data.dll Additional information: ExecuteNonQuery : the Connection property has not been initialized. Thank you :)
You must instantiate the connection and then open a database. Here is an example OdbcConnection cnn = new OdbcConnection("DSN=DATABASE"); cnn.Open(); The parameter in this case would be the connection string. There are many different ways the connection string may be formed. It depends partially on which database type you are opening (SQL Server, MsAccess, Oracle, etc)