所以这是我的代码:
protected void Button1_Click(object sender, EventArgs e)
{
string connectionString = "Data Source= *** ;Integrated Security=True;";
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connectionString);
conn.Open();
string queryString = "INSERT INTO [Iliako_Sistima] (name,apostasi_apo_earth,arithmos_planiton,imerominia_entopismou) VALUES ('"+TextBoxName.Text+"','"+TextBoxEarthDistance.Text+"','"+TextBoxPlanets.Text+"','"+DropDownMonth.Text+"'/'"+DropDownDay.Text+"'/'"+DropDownYear.Text+"');";
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(queryString, conn);
try
{
command.ExecuteNonQuery();
}
catch (Exception)
{
//Response.Redirect("Error.aspx", true);
}
conn.Close();
//Response.Redirect("NewSolar.aspx", false);
}
我想在“imerominia_entopismou”列中插入在 3 个 DropDownBoxes 中选择的日期(DropDownDay、DropDownMonth、DropDownYear)
问题是这段代码 ('"+DropDownMonth.Text+"'/'"+DropDownDay.Text+"'/'"+DropDownYear.Text+"') 不会这样做,因为他得到一个 sql 错误
我怎样才能成功我想要的?