Dear friends, do not bother
I do not know what the problem with this code is that all this was the error
I can not fix it
Code is:
Page was loaded in the filling comboBox
private void view_list_User_DDL()
{
try
{
if (scon.State == ConnectionState.Closed)
scon.Open();
SqlDataAdapter sda = new SqlDataAdapter("Select_User_DDL", scon);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
DataTable dt = new DataTable();
sda.Fill(dt);
comboBox2.DataSource = dt;
comboBox2.DisplayMember = "l_name";
comboBox2.ValueMember = "id_user";
}
catch (Exception err)
{
MessageBox.Show("ERROR" + err, "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
finally
{
scon.Close();
}
}
And here is the next code
:
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (scon.State == ConnectionState.Closed)
scon.Open();
SqlCommand scm = new SqlCommand("Select_Lname_Fname", scon);
scm.CommandType = CommandType.StoredProcedure;
scm.Parameters.AddWithValue("@id_user", comboBox2.SelectedValue);
SqlDataReader sdr = scm.ExecuteReader();
if (sdr.HasRows)
{
sdr.Read();
label10.Text = sdr[0].ToString();
sdr.Close();
}
}
catch (Exception err)
{
MessageBox.Show("ERROR" + err, "اخطار", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
finally
{
scon.Close();
}
}
Here is a program error
Khvahsha friends help me
Thank you
ERRORSystem.ArgumentException: No mapping exists from object type System.Data.DataRowView to a known managed provider native type.
at System.Data.SqlClient.MetaType.GetMetaTypeFromValue(Type dataType, Object value, Boolean inferLen, Boolean streamAllowed)
at System.Data.SqlClient.SqlParameter.GetMetaTypeOnly()
at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc)
at System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters)
at System.Data.SqlClient.SqlCommand.BuildRPC(Boolean inSchema, SqlParameterCollection parameters, _SqlRPC& rpc)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at ShafieiNan.Sel.comboBox2_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\PCTirTash\documents\visual studio 2010\Projects\ShafieiNan\ShafieiNan\Sel.cs:line 292