本文介绍了如何修复此错误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();
}




请帮助!

谢谢!

解决方案

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!

解决方案


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

08-30 02:45