C# SQL占位符

C# SQL占位符
            string connString = ConfigurationManager.AppSettings["SqlConn"].ToString();
            var conn=new SqlConnection(connString);
           
            //var cmd = new SqlCommand("SELECT alliance,ballid FROM talliance with(nolock) WHERE type=8 AND alliance like ‘%‘+@alliance;");
            var cmd = new SqlCommand("SELECT alliance,ballid FROM talliance WHERE type=8 AND alliance like ‘‘+  @alliance +‘%‘;");
            cmd.Parameters.Add(new SqlParameter("@alliance", SqlDbType.NVarChar, 1000));
            //cmd.Parameters[0].Value = "||ATP Sydney international match";
            cmd.Parameters[0].Value = "ATP 悉尼國際賽||";
            cmd.Connection = conn;
            conn.Open();
            var dr =  cmd.ExecuteReader();
            while (dr.Read())
            {
                Console.WriteLine("alliance:"+dr[0].ToString() +"---"+"ballid:"+dr[1].ToString());
            }
            dr.Dispose();
            conn.Close();
            Console.ReadKey();
C# SQL占位符

C# SQL占位符,布布扣,bubuko.com

C# SQL占位符

上一篇:MyEclipse连接SQL Server 2008数据库的操作方法


下一篇:mysql和sql server 多表连接修改 update sql语句总结