PDA

View Full Version : سوال: فوري::::دليل ظاهر شدن اين خطا



navid1n2000
جمعه 29 آبان 1388, 15:11 عصر
من كد زيرو كه ديباگ مي كنم :


SqlConnection objConnection = new SqlConnection("Server=ASAD-2DB92FD23F;Database=VamDB;Integrated Security = True");
SqlDataAdapter objDataAdapter1 = new SqlDataAdapter();
DataSet objDataSet10;
DataView objDataView;
DataTable dt = new DataTable();
objDataAdapter1.SelectCommand = new SqlCommand();
objDataAdapter1.SelectCommand.Connection = objConnection;
objDataAdapter1.SelectCommand.CommandText = "SELECT * FROM n WHERE ShOzviat in (" + str1 + ")";
objDataAdapter1.SelectCommand.CommandType = CommandType.Text;
objDataSet10 = new DataSet();
objConnection.Open();
objDataAdapter1.Fill(objDataSet10, "n");
objConnection.Close();
objDataView = new DataView(objDataSet10.Tables["n"]);
objDataAdapter1.Fill(objDataSet10);
CrystalReport1 cry = new CrystalReport1();
cry.SetDataSource(objDataAdapter1);
crystalReportViewer1.ReportSource = cry;

اين خطارو ميده :
The data source object is invalid.
دليلش چيه ؟

Reza_Yarahmadi
جمعه 29 آبان 1388, 17:07 عصر
به جای دستور زیر یکی از معادلهاشو بذارید

cry.SetDataSource(objDataAdapter1);
//
//
cry.SetDataSource(objDataView);
//OR
cry.SetDataSource(objDataSet10.Tables[0]);