string sqlString =$"insert into Students(StudentName,Gender,Birthday,AttendanceNO,Stulmage,Age,Phone,StudentAddress)VALUES({students.StudentName},{students.Gender},{students.Birthday},{students.AttendanceNO},{students.Stulmage},{students.Age},{students.Phone},{students.StudentAddress})";
uj5u.com熱心網友回復:
string.Format("……{0}……{2}……{1}……{1}", str0, str1, str2);最侄訓得到"……str0……str2……str1……str1"
也就是:按序號所對應的引數對模板進行插值替換。
說句題外的,你這種情況,可以考慮升級一下c#版本,及時更新自己的知識庫是一件有益的事。
uj5u.com熱心網友回復:
樓主的寫法挺好的,沒有必要改。uj5u.com熱心網友回復:
剛反應過來,你這sql有問題。如果一定要用拼接的方法生成sql,那么非數值的欄位需要在兩側用引號手感起來。當然最好的選擇是用引數化查詢。轉載請註明出處,本文鏈接:https://www.uj5u.com/net/272109.html
標籤:C#
