Click here to Skip to main content
15,893,486 members

Comments by Member 11057488 (Top 27 by date)

Member 11057488 30-Jun-15 11:38am View    
it works. thank you
Member 11057488 24-Apr-15 6:24am View    
thank you
Member 11057488 24-Apr-15 5:43am View    
same issue actually unable to cast the oject error is thown on this code and in the first code the exception thrown is index out of bound
Member 11057488 24-Apr-15 5:34am View    
private void button1_Click(object sender, EventArgs e)
{

try
{
conn.Open();

cmd = new SqlCommand(@"INSERT INTO [pix].[dbo].[ProductDetails] ([ProductID],[Modelno],[Price],[Quantity]) VALUES ('" + Convert.ToInt32(comboBox1.SelectedItem) + "','" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "')", conn);// here i got this error unable to cast object of type system.data.datarowview to typ system.iconvertible
int i = 0;
i = cmd.ExecuteNonQuery();
if (i > 0)
{
MessageBox.Show("Rows inserted successfully");
}
else
{
MessageBox.Show("No rows inserted");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
conn.Close();
}
finally
{
conn.Close();
Bind();
}
cleardata();

}
Member 11057488 24-Apr-15 3:48am View    
unable to cast object of type system.data.datarowview to typ system.iconvertible in c#.net index out of bound

public void Bind()
{
try
{
string query = @"select ProductMaster.id,ProductMaster.pName,ProductDetails.Modelno,ProductDetails.Price,ProductDetails.Quantity from ProductMaster, ProductDetails";
sda = new SqlDataAdapter(query, conn);
dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
dataGridView1.DataSource = dt;
}
dataGridView1.Columns[0].Visible = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}