Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I developed a Windows Based Application and installed the setup.exe created by using VS C#2.0 on other PC to check accuracy , after properly installing the application on Windows Vista it successfully established the connection to SQL Server 2005. There are many form in this application viz; 'New Order', 'Generate Bill', 'Final Payment' and 'Purchase Details' etc. When I enter data by using the 'Purchase Details' form, data successfully submitted to database, but when I enter data by using the 'New Order' form and click the submit button the application stops working immediately and gives an error message as like:-
CSS
Description:
  Stopped working

Problem signature:
  Problem Event Name:   CLR20r3
  Problem Signature 01: billing_software.exe
  Problem Signature 02: 1.0.0.0
  Problem Signature 03: 522ed0d8
  Problem Signature 04: System.Data
  Problem Signature 05: 2.0.0.0
  Problem Signature 06: 49cc5f1a
  Problem Signature 07: 2492
  Problem Signature 08: 2c
  Problem Signature 09: System.Data.SqlClient.Sql
  OS Version:   6.0.6002.2.2.0.768.2
  Locale ID:    16393

Read our privacy statement:
  http://go.microsoft.com/fwlink/?linkid=50163&clcid=0x0409

I am giving herewith the New Order Submit button code sample:-
CSS
private void button1_Click(object sender, EventArgs e)
        {
            string s = "insert into New_Order values('" + comboBox1.Text + "','" + comboBox2.Text + "','" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + dateTimePicker1.Value + "','" + dateTimePicker2.Value + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "')";
            SqlConnection con = new SqlConnection(Class1.cs);
            con.Open();
            SqlCommand cmd = new SqlCommand(s, con);
            cmd.ExecuteNonQuery();
            MessageBox.Show("Information Saved Successfully");
            textBox3.Text = "";
            comboBox2.Text = "";
            textBox1.Text = "";
            textBox4.Text = "";
            textBox2.Text = "";
            dateTimePicker1.Text = "";
            dateTimePicker2.Text = "";
            textBox5.Text = "";
            textBox6.Text = "";
            textBox7.Text = "";
            textBox8.Text = "";
            con.Close();
            string s1 = "select * from Sales_Details where Challan_No='" + comboBox1.Text + "'";
            SqlConnection cn = new SqlConnection(Class1.cs);
            cn.Open();
            SqlDataAdapter da = new SqlDataAdapter(s1, cn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];
            cn.Close();
        }



I am not finding the reason behind it, pleasesomeone help me.
Posted
Updated 10-Sep-13 17:15pm
v5
Comments
lukeer 10-Sep-13 5:17am    
Did you write that software?
Then use the "Improve question" link and provide the code that's being run on clicking the submit button on the NewOrder form.

If that's a software you don't have the source code for, ask the creator/vendor/publisher.
Joezer BH 10-Sep-13 5:38am    
The best idea you will get by asking the developer of the software, there's very little we can do with your info...
Md M Ahmad 10-Sep-13 10:49am    
Sir, I have developed the software.
ZurdoDev 10-Sep-13 7:56am    
You need to debug it. Add some logging features to it.
Md M Ahmad 10-Sep-13 11:23am    
Sir, sorry didn't understand logging features??

1 solution

Change that button click handler a littel, with a try catch blcok (and I'd also suggest a parameterized query):
C#
private void button1_Click(object sender, EventArgs e)
{
    try
    {
        //your code here
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Tostring());
    }
}

At least, the application won't crash away totally, and you'll get a better error message.
 
Share this answer
 
Comments
Md M Ahmad 11-Sep-13 6:22am    
I used it the application throws an error:
Error:- System.Data.SqlClient.SqlException: The conversion of a char data type to a datetime datatype resulted in an out-of-range datetime value.
The statement has been terminated.
Bernhard Hiller 11-Sep-13 9:27am    
You see: the problem is not so obscure. Likely a different format for date and time on that specific computer. Can be easily resolved with a parameterized query.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900