First off, don't hard code your connection string your code behind file. You should put the config in your web.config file under connectionString element.
Second, appending the values from your input to your SQL statement is a big NO NO, as it can lead you to SQL injection attack. Read:
Protect Your Data: Prevent SQL Injection[
^]
Third, make it a habit to put objects that eat resources such as SqlConnection, SqlCommand and SqlDataAdapter within a using statement to ensure that objects will be properly disposed and closed after they are used.
Fourth, Do not use DataSet when you are only dealing with 1 result set. Instead you could use a DataTable.
Fifth, Don't mix SqlDataSource with your ADO.NET code. If want to do database operation by hand then stick to ADO.NET way.
You can rewrite your code to this:
protected void Button1_Click(object sender, EventArgs e) {
DataTable dt = new DataTable();
using (SqlConnection sqlConn = new SqlConnection
(ConfigurationManager.ConnectionStrings["YourDBConnectionString"].ConnectionString)){
string sql = "INSERT INTO dbo.STANDARDS VALUES (@Param1,@Param2)";
using(SqlCommand sqlCmd = new SqlCommand(sql,sqlConn)){
sqlCmd.Parameters.AddWithValue("@Param1", TextBox1.Text);
sqlCmd.Parameters.AddWithValue("@Param1", DropDownList1.SelectedValue);
sqlConn.Open();
using(SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlCmd)){
sqlAdapter.Fill(dt);
}
}
}
if(dt.Rows.Count > 0){
}
}
Your error typically means that you are trying to update foreign key column (S_ID) in your STANDARDS table which do not exists in reference table (SCHOOL table).
You should check your constraint again.