sqlComm.Connection = sqlConn;
sqlComm.Parameters.AddWithValue("@Kullanici", Kullanici);
sqlComm.Parameters.AddWithValue("@Sifre", Sifre);
sqlComm.Parameters.AddWithValue("@Ad", Ad);
sqlComm.Parameters.AddWithValue("@Soyad", Soyad);
sqlComm.Parameters.AddWithValue("@Parametre", rndParametre);
sqlComm.CommandText = "INSERT INTO Kullanici (EPosta,Sifre,Ad, Soyad,Aktif,Parametre, __DZamani) " +
" VALUES (@Kullanici,@Sifre,@Ad,@Soyad, 0,@Parametre,getdate()); SELECT RecID FROM Kullanici WHERE EPosta= "+ Kullanici;
sqlConn.Open();
SqlDataReader sqlRead = sqlComm.ExecuteReader();
while (sqlRead.Read())
{
RecID = Convert.ToInt32(sqlRead["RecID"]);
}
sqlConn.Close();
Run Code Online (Sandbox Code Playgroud)
我有错误: 多部分标识符"some@email.com"无法绑定 如何修复此错误?你有什么主意吗?
这就是问题所在:
SELECT RecID FROM Kullanici WHERE EPosta= "+ Kullanici;
Run Code Online (Sandbox Code Playgroud)
您没有引用该VARCHAR/NVARCHAR字段,因此SQL认为这是一个无法找到的表名.
你应该使用与其他地方相同的参数 - 这里不清楚为什么,只有在这里你连接SQL.这将打开SQL注入,因此您应该使用已有的参数:
SELECT RecID FROM Kullanici WHERE EPosta= @Kullanici";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2852 次 |
| 最近记录: |