应用程序在特定PC上部分工作 [英] Application working partially in a particular PC
问题描述
我开发了一个基于Windows的应用程序,并在其他PC上安装了使用VS C#2.0创建的setup.exe,以检查准确性,在Windows Vista上正确安装该应用程序后,它成功建立了与SQL Server 2005的连接.在本申请表中形成; 新订单",生成账单",最终付款"和购买详细信息" 等.当我使用''购买详细信息输入数据时''表单,数据已成功提交到数据库,但是当我使用''New Order ''表单输入数据并单击Submit按钮时,应用程序立即停止工作并出现错误像这样的消息:-
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:-
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:-
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.
推荐答案
更改该按钮单击处理程序为小对象,并尝试抓住blcok(我也建议参数化查询):
Change that button click handler a littel, with a try catch blcok (and I''d also suggest a parameterized query):
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.
这篇关于应用程序在特定PC上部分工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!