如何修复此错误SqlException未处理(System.Data.SqlClient.SqlException) [英] How to fix this error SqlException was unhandled (System.Data.SqlClient.SqlException)

查看:102
本文介绍了如何修复此错误SqlException未处理(System.Data.SqlClient.SqlException)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好 


我遇到了这个问题:


这是例外 抛出dr = com.ExecuteReader(); 

 private void pneu_SelectedIndexChanged(object sender,EventArgs e)
{
SqlCommand com = new SqlCommand();
SqlConnection con = new SqlConnection("Data Source = CHAIMA; Initial Catalog = OptiMaint; Integrated Security = True");
SqlDataReader dr;
com.CommandText ="从dbo.ORGANES中选择ORG_DESIGNATION,ORG_FAMILLE,ORG_GROUPE,ORG_PRIX_ACHAT,ORG_IMAGE,其中dbo.ORGANES ='" + pneu.Text +"'" ;;
com.Connection = con;
con.Open();
dr = com.ExecuteReader(); //
while(dr.Read())
{
textBox1.Text = dr [" ORG_DESIGNATION&qu​​ot;]。ToString();
textBox2.Text = dr [" ORG_FAMILLE"]。ToString();
textBox3.Text = dr [" ORG_GROUPE"]。ToString();
textBox4.Text = dr [" ORG_PRIX_ACHAT"]。ToString();
photo.ImageLocation = dr [" ORG_IMAGE"]。ToString();
}
con.Close();
}




请帮助!

谢谢!

解决方案

<嗯,你需要发布超过你发布的关于异常的内容,比如内部。 Exception.message,如果有的话。 


https://msdn.microsoft.com/en-us/library/system.exception.innerexception(v = vs.110).aspx


https://www.c-sharpcorner.com/uploadfile/puranindia/innerexception-in-C-Sharp/


你也可以得到inner.Exception如果你在VS调试模式下运行程序,让它爆炸,将产生异常弹出屏幕,你可以点击"查看详细信息"。



good morning 

I have this problem :

This is the exception  thrown at dr = com.ExecuteReader(); 

 private void pneu_SelectedIndexChanged(object sender, EventArgs e)
        {
         SqlCommand com = new SqlCommand();
        SqlConnection con = new SqlConnection("Data Source=CHAIMA;Initial Catalog=OptiMaint;Integrated Security=True");
            SqlDataReader dr;
            com.CommandText = " select  ORG_DESIGNATION , ORG_FAMILLE , ORG_GROUPE ,ORG_PRIX_ACHAT , ORG_IMAGE from dbo.ORGANES where dbo.ORGANES ='" + pneu.Text + "'";
            com.Connection = con;
            con.Open();
            dr = com.ExecuteReader(); // 
            while (dr.Read())
            {
                textBox1.Text = dr["ORG_DESIGNATION"].ToString();
                textBox2.Text = dr["ORG_FAMILLE"].ToString();
                textBox3.Text = dr["ORG_GROUPE"].ToString();
                textBox4.Text = dr["ORG_PRIX_ACHAT"].ToString();
                photo.ImageLocation = dr["ORG_IMAGE"].ToString();
            }
            con.Close();
        }


Kindly Help!
Thank you!

解决方案

Well, you need to post more than what you have posted about the exception, like the inner. Exception.message, if there. 

https://msdn.microsoft.com/en-us/library/system.exception.innerexception(v=vs.110).aspx

https://www.c-sharpcorner.com/uploadfile/puranindia/innerexception-in-C-Sharp/

You can also get the inner.Exception if you run the program in VS debug mode, let it blowup that will produce the exception popup screen , and you can click on "View Details".


这篇关于如何修复此错误SqlException未处理(System.Data.SqlClient.SqlException)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆