|
Bernhard Hiller wrote: how can an existing window handle be lost?
Open a handle to an object and never properly close it, then orphan it by letting the variable that was holding the handle fall out of scope.
In a .NET app, that's quite easily done by, say, creating a Graphics object and never calling Dispose on it when your done with. Or by allocating a Font, Brush, Pen, Stream, ... by no means an exhaustive list.
Bernhard Hiller wrote: In one case, our application crashed at an Invoke: the window handle did no more
exist. A dialog had been opened, a control with its own window handle had been
used succesfully; then the user had a break, the computer was locked (session
switch event); after unlocking an hour later, the user did something else on the
computer before using our program again, and then it immediately crashed due to
the missing handle. I do not understand that. We did not Dispose() of it.
I don't have a clue there. You'd have the find out what else is running on the machine, such as virus scanner, and see if you can replicate the problem outside of their environment.
|
|
|
|
|
Hi
i have two forms , first form has a datagrid to show Rows record of table and Second Form is the details of every record in dataGrid , when we double Click the row .
In the Second Form , I need to Update Records . So I check the record ("RegNo") is Duplicate for a specific Year.
Here is My code . But I couldn't Update the Records ...:
-----
try
{
if (txtFname.Text == FnameDataGrid && txtLname.Text == LnameDataGrid
&& txtRegNo.Text == RegNoDataGrid && txtYearReg.Text == YearRegDataGrid)
{
OleDbConnection ocn_Edited = new OleDbConnection(ConnectionStringEdited);
OleDbCommand ocmd_Edited = new OleDbCommand();
ocmd_Edited.CommandText = @"UPDATE RegTable SET FNAME=@p1,LNAME=@p2,
YearReg=@p3,RegNo=@p4,
WHERE YearReg=@g1
AND RegNo=@g2";
ocmd_Edited.Parameters.Clear();
ocmd_Edited.Parameters.AddWithValue("@p1", txtFname.Text);
ocmd_Edited.Parameters.AddWithValue("@p2", txtLname.Text);
ocmd_Edited.Parameters.AddWithValue("@p3", txtYearReg.Text);
ocmd_Edited.Parameters.AddWithValue("@p4", txtRegNo.Text);
ocmd_Edited.Parameters.AddWithValue("@g1", YearRegDataGrid);
ocmd_Edited.Parameters.AddWithValue("@g2", RegNoDataGrid);
ocmd_Edited.Connection = null;
ocmd_Edited.Connection = ocn_Edited;
ocn_Edited.Open();
ocmd_Edited.ExecuteNonQuery();
ocn_Edited.Close();
ocmd_Edited.Dispose();
ocn_Edited.Dispose();
MessageBox.Show(" ... This Table Updated ...");
frmShowGrd frmGrd = (frmShowGrd)Application.OpenForms["frmShowGrd"];
frmGrd.boolEdit = true;
frmGrd.FnameDataGrid_1 = txtFname.Text;
frmGrd.LnameDataGrid_1 = txtLname.Text;
frmGrd.YearRegDataGrid_1 = txtYearReg.Text;
frmGrd.RegNoDataGrid_1 = txtRegNo.Text;
this.Close();
}
else
{
OleDbConnection ocn = new OleDbConnection(ConnectionStringEdited);
strSql =@"SELECT RegNo WHERE RegNo=@s1 AND YearReg=@s2";
OleDbDataAdapter oda_Edited = new OleDbDataAdapter(strSql, ocn);
oda_Edited.SelectCommand.Parameters.Clear();
oda_Edited.SelectCommand.Parameters.AddWithValue(" @s1", txtRegNo.Text);
oda_Edited.SelectCommand.Parameters.AddWithValue(" @s2", txtYearReg.Text);
DataTable dt_Edited = new DataTable();
dt_Edited.Clear();
oda_Edited.Fill(dt_Edited);
if (dt_Edited.Rows.Count > 0)
{
MessageBox.Show("Already Exists!! ");
txtRegNo.Focus();
}
else
{
OleDbCommand ocmd_Edited02 = new OleDbCommand();
ocmd_Edited02.CommandText = @"UPDATE RegTable SET FNAME=@t1,LNAME=@t2,
YearReg=@t3,RegNo=@t4,
WHERE YearReg=@e1
AND RegNo=@e2";
ocmd_Edited02.Parameters.Clear();
ocmd_Edited.Parameters.AddWithValue("@t1", txtFname.Text);
-----
I don't don't where's my Mistake .
Plz Help Me .
Thanks
modified 3-Sep-13 8:16am.
|
|
|
|
|
smh1392 wrote: But I couldn't Update the Records
What does that mean? Do you get an error message? If so, tell us the message. Does the table contain values different from those you expected? Does "first form" still show old values instead of the updated values? Anything else different from what you expected?
|
|
|
|
|
according to the code that I wrote above , I want to check the Value of "RegNo" (preventing duplicate the value of "RegNo" Field ), before Updating , but Always Execute this :
if (dt_Edited.Rows.Count > 0)
{
MessageBox.Show("Already Exists!! ");
txtRegNo.Focus();
}
So my database never Update ...
....
Thanks
|
|
|
|
|
Is there is way to invoke solid edge using c#
Thanks
|
|
|
|
|
|
Thanks For reply
But not get proper answer
|
|
|
|
|
If you give a proper question, you'll get a proper answer. As I asked, what is Solid Edge? I could have assumed it was the CAD package, but that would have been an assumption which could have ended up wasting your time by supplying details of something that was completely inappropriate.
|
|
|
|
|
I Want to create Solid Edge drawing using C# application
Thanks
|
|
|
|
|
Again, WHAT IS SOLID EDGE??
When speaking with humans, the quality of the answer you get is directly dictated by the quality of the question you ask!
|
|
|
|
|
Thanks..
Solid edge is a software for making mechanical 3D drawings...I is just Like Autocad Software used for mechanical engineers drawings..
Thanks
|
|
|
|
|
The best place to ask your question would be the makers of SolidEdge, not a bunch of people who have never heard of it.
|
|
|
|
|
Not sure - but this set[^] of samples on Codeplex might help you.
|
|
|
|
|
|
My SQL command returns 3 rows which is verified in a SQL GUI. I run the same code and SqlDataReader returns only 2 of them. The same sql command returns 3 rows with SqlDataAdapter. Here is my code.
ds has 3 rows.
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["VPO"].ConnectionString))
{
string sql="SELECT DISTINCT A.account_id, A.fname, A.lname,
FROM T_Test1 A WITH (NOLOCK) JOIN T_Test2 AF WITH (NOLOCK) ON A.Account_id=AF.Account_id
WHERE account_status = 'A' AND A.card IS NOT NULL
AND A.dateFrom >= '09-02-2013 00:00:00' AND A.dateFrom <= '09-30-2013 00:00:00' AND AF.code = 'INE'";
SqlCommand command = new SqlCommand(sql.ToString(), connection);
command.CommandTimeout = 3600;
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{}
}
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(command.CommandText, connection);
da.Fill(ds);
}
|
|
|
|
|
I know that isn't an answer to your question but why are you executing this query twice?
NarVish wrote: using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{}
}
and
NarVish wrote: DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(command.CommandText, connection);
da.Fill(ds);
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Just to show the difference, I added the SqlDataAdapter code. It will be removed.
|
|
|
|
|
what happens if the you run the query direct on your database?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
If I run the query on database (SQL GUI), it is showing three records
|
|
|
|
|
What are the three rows, and which one is not being returned?
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
DataReader didn't read first record.
|
|
|
|
|
Hm. Unlikely - but suspicious.
I use code very similar to yours every day - and it has never missed out a row (particularly not the first row). I notice that the code you show a fragment of isn't the code you are actually using - can you post that bit? It seems unlikely that a "missing the first row" problem would be that specific is it was an SQlReader bug. Oh, and can you show the three rows worth of data and I'll try it here, see what happens.
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
NarVish wrote: I run the same code and SqlDataReader returns only 2 of them. The DataAdapter does not remove records from the resultset that it receives.
NarVish wrote: AND A.dateFrom >= '09-02-2013 00:00:00' AND A.dateFrom <= '09-30-2013 00:00:00' Are you sure those dates are correctly interpreted?
Use a parameterized query to prevent questions like those
Further, "sql" is already a string (no need to call .ToString) and SqlCommand is a disposable.
NarVish wrote: My SQL command returns 3 rows which is verified in a SQL GUI. Also do verify that you're pointing to the same database in both environments.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Also do verify that you're pointing to the same database in both environments
Good thing to point out! I've been bitten by that one before.
Cheers!
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
|
|
|
|
|
I'm suspicious that you're missing the code inside reader.Read(). I have the feeling that the problem you are looking at lies in that block. As a test, replace your reader.Read line with this
int count = 0;
while (reader.Read())
{
Debug.WriteLine("Count is {0}", ++count); Then, when you are debugging your app, take a look at what appears in the output window in Visual Studio.
|
|
|
|