Cj Mah

Cj Mah

  • NA
  • 0
  • 2k

i need help in editresource code

Dec 28 2015 11:54 PM
i want to used it for my project but the problem is this code, the error message is invalid column name "Type".
 
int id = 0;
SqlConnection conn = null;
SqlCommand cmd = null;
string connectionString = null;
 
 
protected void btnSubmit_Click(object sender, EventArgs e)
{
connectionString = ConfigurationManager.ConnectionStrings["FacilityCS"].ConnectionString;
conn = new SqlConnection(connectionString);
string sql = "UPDATE Resource SET Type=@type, Description=@description, Location=@location,";
sql+=" Abr=@abr, Description=@description, Capacity=@capacity, Details=@details, Level=@level From";
sql += " Resource INNER JOIN ResourceType ON ResourceType.Id=ResourceType.Id";
sql += " WHERE Resource.Id=@id";
try
{
cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddWithValue("@type", Convert.ToInt32(ddlType.SelectedValue));
cmd.Parameters.AddWithValue("@description", tbDescription.Text);
cmd.Parameters.AddWithValue("@location", tbLocation.Text);
cmd.Parameters.AddWithValue("@abr", tbAbr.Text);
cmd.Parameters.AddWithValue("@details", tbDetails.Text);
cmd.Parameters.AddWithValue("@capacity", tbCapacity.Text);
cmd.Parameters.AddWithValue("@level", tbLevel.Text);
cmd.Parameters.AddWithValue("@id", lblIdOut.Text);
conn.Open();
int row = cmd.ExecuteNonQuery();
if(row>0)
{
lblOutput.Text = "Record Updated successfully";
}
}
 

Answers (3)