日期:2014-05-17 浏览次数:20550 次
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Data; using System.Web; /// <summary> ///Class1 的摘要说明 /// </summary> /// public class Class1 { public static Boolean login(String name,String pass) { SqlConnection MyConnection = new SqlConnection("server=.;uid=sa;pwd=yk_123;database=poject"); MyConnection.Open(); SqlCommand sql = new SqlCommand("select * from member where mname=@name and mpass=@pass"); SqlParameter pa = new SqlParameter("@name",SqlDbType.VarChar,50); pa.Value =name; SqlParameter pa1 = new SqlParameter("@pass",SqlDbType.VarChar,50); pa1.Value = pass; sql.Parameters.Add(pa); sql.Parameters.Add(pa1); int rs = sql.ExecuteNonQuery(); if (rs > 0) { return true; } else { return false; } } }
SqlConnection conn = new SqlConnection(); SqlCommand cmd = new SqlCommand("sql", conn);