当我运行的时候 比如在dropdownlist里选的是“大专以下”
它就出现: ‘大专以下’附近有语法错误。字符串‘)’之前有未闭和的引号。
我实在是找不出问题在哪 望各位赐教呀。
部分源码如下:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Text;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
private void Button1_Click(object sender, System.EventArgs e)
{
SqlConnection myConnection=new SqlConnection(DataBaseDB.ConnectionString);
string Aacademic;
if(academic.SelectedIndex==3)Aacademic="硕士以上(含硕士)";
else if(academic.SelectedIndex==2)Aacademic="本科";
else if(academic.SelectedIndex==1)Aacademic="专科";
else Aacademic="大专以下";string Ssex;
if(sex.SelectedIndex==2)Ssex="女";
else if(sex.SelectedIndex==1)Ssex="男";
else Ssex="不限";
string sql="insert into companyinfo(type,name,space,mainjob,worktime,wage,skill,phone,date,person,other,time,age,academic,sex) values('"+this.Type.Text+"','"+this.Name.Text+"','"+this.Space.Text+"','"+this.Mainjob.Text+"','"+this.Worktime.Text+"','"+this.Wage.Text+"','"+this.Skill.Text+"','"+this.Phone.Text+"','"+this.Date.Text+"','"+this.Person.Text+"','"+this.Other.Text+"','"+this.Time.Text+"','"+this.Age.Text+"'','"+Aacademic+"','"+Ssex+"')";
SqlCommand myCommand=new SqlCommand(sql,myConnection);
myConnection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
try{myCommand.ExecuteNonQuery();}
catch{ }
finally
{
myCommand.Dispose();
myConnection.Close();
Response.Write("<script>alert(\"恭喜您,系统已经接受了您的信息!!!\")</script>");
}
this.Type.Text="";
this.Name.Text="";
this.Space.Text="";
this.Mainjob.Text="";
this.Worktime.Text="";
this.Wage.Text="";
this.Skill.Text="";
this.Phone.Text="";
this.Date.Text="";
this.Person.Text="";
this.Other.Text="";
this.Time.Text="";
this.Age.Text="";
}