|
hi
i will insert info person to database and i use janus control and bind all input from databinding and bind picturebox and mathimage that is editbox
and in run accure error:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows
my code:
save:
try
{
bimehgozarBindingSource.EndEdit();
bimehgozarTableAdapter.Update(this.bimehDataSet.bimehgozar);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
new:
bimehgozarBindingSource.AddNew();
string query = "SELECT MAX(code_bg) FROM bimehgozar";
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=bimeh;Integrated Security=True");
SqlCommand comSelect = new SqlCommand(query, con);
con.Open();
string ID = comSelect.ExecuteScalar().ToString();
if (ID == "")
editBox8.Text = 1.ToString();
else
{
int a = Convert.ToInt32(ID);
a = a + 1;
editBox8.Text = a.ToString();
}
editBox1.Text = "";
editBox2.Text = "";
editBox3.Text = "";
editBox4.Text = "";
editBox5.Text = "";
editBox6.Text = "";
editBox7.Text = "";
editBox11.Text = "";
editBox12.Text = "";
editBox13.Text = "";
editBox14.Text = "";
pictureBox1.Image = null;
i am accure errore in save Button click
please help me i am tired. how save image when use janus control beacuse i use janus control not have value for insert.
wheather i need to convert image to array.
please guide me i want to insert info and long time accure error.
best regards
|
|
|
|
|
If you have a problem with Janus control, perhaps you need to contact the support forums for the people who wrote it. They will be the best placed to answer questions like this.
|
|
|
|
|
thanks i put my question in many forum of programing but i just now
my question in janus forum.
|
|
|
|
|
hello,
I developed a C # application I am connecting to the database , when I do a simple query the application launches and data are collected in the datagridview . but when I want to retrieve a lot of data and I run I click run the windows form does not appear and nothing appears .
Thank you
|
|
|
|
|
Well then ... don't do that! ("read a lot of data").
Use virtualization.
|
|
|
|
|
I have to retrieve a lot of data on my datagridview
|
|
|
|
|
You have 5 possible choices.
1) Use Virutalization on the DataGridView and only retrieve the records that are being displayed.
2) Use Virtualization...
3) Use Virtualization...
4) Use Virtualization...
5) Put up with the situation you have because the long part of this process is more than likely the number of rows you're trying to stuff into the grid, not the speed of the retrieval of those rows. As a rule of thumb, it takes 10 times longer to get the grid to show the data than it does to retrieve it.
|
|
|
|
|
is that you have a tutorial to use virtualization?
|
|
|
|
|
Google for "C# DataGridView Virtualization"
|
|
|
|
|
Do you really? How much is a lot? Have you checked with your users that they want to see all that data in one go? You'll be surprised at how little users really want to wade through screens of data.
If you must retrieve it all in one go though, retrieve it on a background thread, and then marshal the data back onto the UI thread.
|
|
|
|
|
how to do a background thread , and then collect the data back to the UI thread .
|
|
|
|
|
The easiest way to get started with this is to use something called the Task Parallel Library. Have a search here on CodeProject for Sacha Barber's articles on it; that should get you started.
|
|
|
|
|
Can you be more specific? What do you mean with "lots of data" ? 10 000 records, 100 000? 1 000 000?
Secondly is it working in debug and not in release or does it work, but when you click (a button?) the form dissapears? Do you get an error message? ...
|
|
|
|
|
hi,
a lot of data 1000000, there is no error the application takes too long to display (3hours).
|
|
|
|
|
all righty, that's already more clear.
First of all, 1 000 000 records in one go is just a big NO.
As an exercise calculate the size (in bytes) of one record and multiply that by 10^6. That amount of data is transferred through the wire... In addition your objects in code will also be too large memory wise.
Your best bet is to fetch this stuff in bits and parts. The first idea that comes to mind is to use paging, although for a million records this still a 1000 pages of a 1000 records.
In addition to that paging you'll need to filter the data to what users would like to see. You start with an empty grid and allow the user to filter on several columns before fetching anything.
3 hours is a long time. Make sure the query is optimized and the indexes on the database are properly built.
You'll probably need to fiddle with both the code part and the database in order to come to a good solution.
As rule of thumb any collection larger then let's say 10 000 is a no go. (I'm talking normal records, not blobs with huge amounts of data). (This number is not a rule, 100 can be already too much and in some cases 50 000 can still work ok)
This is not a simple problem, take your time to handle it right.
Hope this helps.
|
|
|
|
|
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
|
|
|
|
|
The error is pretty explicit:
the Connection property has not been initialized.
So look at your code: check that you have created an SqlConnection object using the correct connection string, that you have opened the connection, and that you have attached it to the SqlCommand:
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("SELECT iD, description FROM myTable", con))
{
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
int id = (int) reader["iD"];
string desc = (string) reader["description"];
Console.WriteLine("ID: {0}\n {1}", iD, desc);
}
}
}
}
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I put :
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
connection.Open();
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();
|
|
|
|
|
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!
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 as searchForText 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
Thank you
|
|
|
|
|
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.
|
|
|
|
|
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.
|
|
|
|