???SQL Server?????????
???????????? ???????[ 2016/7/1 11:04:05 ] ????????????? SQL Server
?????????????????е??????
????SELECT cacheobjtype??objtype??usecounts??sql FROM sys.syscacheobjects
????WHERE sql LIKE '%Users%' and sql not like '%syscacheobjects%'
???????????????
????????????????????????????????ò????????????????????????????????崫?????????????????????????????
??????????????????????????????????????varchar??nvarchar??char??nchar???????int??bigint??decimal??datetime????????????????????????(???????????????)?????????????UserID?int????????????????2??20??-1???????????????(@UserIDint)select*from Users where UserID=@UserID
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "select * from Users where UserID=@UserID";
//??? 2??????????2
//??м??(@UserID int)select * from Users where UserID=@UserID
comm.Parameters.Add(new SqlParameter("@UserID"?? SqlDbType.Int?? 2) { Value = 2 });
comm.ExecuteNonQuery();
}
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "select * from Users where UserID=@UserID";
//??? 2??????????20
//??м??(@UserID int)select * from Users where UserID=@UserID
comm.Parameters.Add(new SqlParameter("@UserID"?? SqlDbType.Int?? 20) { Value = 2 });
comm.ExecuteNonQuery();
}
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "select * from Users where UserID=@UserID";
//??? 2??????????-1
//??м??(@UserID int)select * from Users where UserID=@UserID
comm.Parameters.Add(new SqlParameter("@UserID"?? SqlDbType.Int?? -1) { Value = 2 });
comm.ExecuteNonQuery();
}
????????????£???????varchar(max)??nvarchar(max)?????????????????趨?????-1????
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "select * from Users where UserName=@UserName";
//?????varchar(max)???????????????-1
//??????? (@UserName varchar(max) )select * from Users where UserName=@UserName
comm.Parameters.Add(new SqlParameter("@UserName"?? SqlDbType.VarChar??-1) { Value = "username1" });
comm.ExecuteNonQuery();
}
????????????????ò????????????????SQL??????????в??????????????????????????SQL????????
???????????????????弰????
????1.??????SQL???
????2.?????????????(??????????ò?????)???????????????????????
????3.????????????????????????(varchar??nvarchar??char??)???????????????????????????(int??bigint??decimal??datetime??)?????????????????
????4.????varchar(max)????nvarchar(max)???????????????-1????
????5.??????Щ?Ь????洢?????????????????????Щ??????????£?????????洢????????????????????????????????????????洢?????ж????????????????????????????????????????±????????????????????????洢????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11