问题描述
大家好/首先抱歉我的英语)))
Hello to all/ Sorry for my English firstly)))
UPDATE Ank_data_women
SET Family = N'3423', Name = N'1', Surname = N'2', Date_birth = '26.05.1990', Phone_number = N'4', Place_birth = 1
FROM Ank_data_women INNER JOIN
Place_birth ON wom.Place_birth = Place_birth.[Key]
WHERE (Ank_data_women.[Key] = 45)
这段代码可以很好地在Sql上工作,但是当我在c#上编写此代码时,我得到了错误
This code goodly work on Sql, but when i write this on c# i get the error
public bool EditMember(string Name, string Family, string Surname, DateTime Date_birth, string Phone_number, int Place_birth)
{
EditPeople edit = new EditPeople();
bool flag = false;
string i= edit.textBox4.Text; //
// MessageBox.Show(Convert.ToString(i));
string query = string.Format("UPDATE Ank_data_women SET Family = @Family, Name =@Name, Surname = @Surname, Date_birth = @Date_birth, Phone_number = @Phone_number, Place_birth = @Place_birth FROM Ank_data_women won INNER JOIN Place_birth ON won.Place_birth = Place_birth.[Key] WHERE (won.[Key] = 45"); //
using (SqlConnection con = new SqlConnection(connectionstring))
{
SqlCommand com = new SqlCommand(query, con);
con.Open();
SqlParameter param = new SqlParameter();
param.ParameterName = "@Family";
param.Value = Family;
param.SqlDbType = System.Data.SqlDbType.NChar;
com.Parameters.Add(param);
param = new SqlParameter();
param.ParameterName = "@Name";
param.Value = Name;
param.SqlDbType = System.Data.SqlDbType.NChar;
com.Parameters.Add(param);
param = new SqlParameter();
param.ParameterName = "@Surname";
param.Value = Surname;
param.SqlDbType = System.Data.SqlDbType.NChar;
com.Parameters.Add(param);
param = new SqlParameter();
param.ParameterName = "@Date_birth";
param.Value = Date_birth;
param.SqlDbType = System.Data.SqlDbType.DateTime;
com.Parameters.Add(param);
param = new SqlParameter();
param.ParameterName = "@Phone_number";
param.Value = Phone_number;
param.SqlDbType = System.Data.SqlDbType.NChar;
com.Parameters.Add(param);
param = new SqlParameter();
param.ParameterName = "@Place_birth";
param.Value = Place_birth;
param.SqlDbType = System.Data.SqlDbType.Int;
com.Parameters.Add(param);
{
if (com.ExecuteNonQuery() == 1)
flag = true;
}
}
return flag;
}
那是我表中的数据
关键家庭|姓名|姓|出生日期|电话号码|出生地点
45格雷戈里·玛塔·史密斯1990年5月26日62-33-33莫斯科
46 sdaf sdsdfds Ssdfs 1990年5月26日22-44-55莫斯科
47 sdfgdfy Marta Smith 1990年5月26日77-77-66莫斯科
48 dsfgdfg sdfgdfs dsfgdf 1990年5月26日88-77-77莫斯科
图片
Thats data in my table
Key | Family | Name | Surname | Date_birth | Phone_number | Place_Birth
45 Gregory Marta Smith 26.05.1990 62-33-33 Moscow
46 sdaf sdsdfds Ssdfs 26.05.1990 22-44-55 Moscow
47 sdfgdfy Marta Smith 26.05.1990 77-77-66 Moscow
48 dsfgdfg sdfgdfs dsfgdf 26.05.1990 88-77-77 Moscow
picture
推荐答案
WHERE (won.[Key] = 45");
应该可能是
should likely be
WHERE (won.[Key] = 45)");
这篇关于构造"45"附近的语法不正确.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!