Sql连接无法正常工作

时间:2014-08-20 06:24:34

标签: c# sql asp.net

我的ConnectionString如下:

add name="TicketingSystemEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=192.168.20.103;initial catalog=TicketingSystem;persist security info=True;user id=sa;password=password;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"

我正在使用此代码:

  public void CreateUser(String FirstName, String LastName, String Email, String Password, String MobileNumber, String DOB)
     {

         string cs = System.Configuration.ConfigurationManager.ConnectionStrings["TicketingSystemEntities"].ConnectionString;

         SqlConnection con = new SqlConnection(cs);
         string query1 = "insert into TEndUsers (FirstName,LastName,Email,MobileNbr,DateOfBirth,PasswordTED) values ("
     + FirstName + "," + LastName + "," + Email + "," + MobileNumber + "," + DOB + Password + ")";
         SqlCommand cmd = new SqlCommand(query1, con);

         con.Open();

         cmd.ExecuteNonQuery();

         con.Close();

它给了我一个argumentException:不支持关键字:'metadata'。

你能帮忙吗?

0 个答案:

没有答案