根据你的数据库自己做些修改
web.config设置:
------------------------------------------------------------------
----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using UserWebModel;
namespace UserWebDAL
{
public static class LoginUserService
{
//获取连接字符串
static string connectionString = ConfigurationManager.ConnectionStrings["DBHelplerDbConnection"].ConnectionString;
//插入输入
public static int InsertEntity(LoginUserInfo loginUserInfo)
{
string sql = "INSERT INTO [PopedomManagement].[dbo].[LoginUser] ([UserName],[UserPassword],[TypeId]) VALUES ('" + loginUserInfo.UserName + "','" + loginUserInfo.UserPassWord + "'," + loginUserInfo.UserTypeInfo.TypeId + ")";
int result = 0;
using (SqlConnection conn = new SqlConnection(connectionString))
{
if (conn.State != ConnectionState.Open)
conn.Open();
SqlCommand cmd = new SqlCommand(sql,conn);
result = Convert.ToInt32(cmd.ExecuteScalar());
conn.Close();
}
return result;
}
//查找数据
public static LoginUserInfo CheckUser(string userName,string userPass)
{
LoginUserInfo loginUserInfo = new LoginUserInfo();
string sql = string.Format("select * from dbo.LoginUser where UserName = '{0}' and UserPassword ='{1}'",userName,userPass);
using (SqlConnection conn = new SqlConnection(connectionString))
{
if (conn.State != ConnectionState.Open)
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
loginUserInfo.UserId = (int)reader["UserId"];
loginUserInfo.UserName = (string)reader["UserName"];
loginUserInfo.UserPassWord = (string)reader["UserPassWord"];
loginUserInfo.UserTypeInfo = UserTypeService.SelectTypeById((int)reader["TypeId"]);
}
}
return loginUserInfo;
}
public static IList
{
IList
string sql = "select * from dbo.LoginUser";
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
LoginUserInfo loginUserInfo = new LoginUserInfo();
loginUserInfo.UserId = (int)reader["UserId"];
loginUserInfo.UserName = (string)reader["UserName"];
loginUserInfo.UserPassWord = (string)reader["UserPassWord"];
loginUserInfo.UserTypeInfo = UserTypeService.SelectTypeById((int)reader["TypeId"]);
list.Add(loginUserInfo);
}
return list;
}
public static void DeleteUser(int id)
{
string sql = "delete dbo.LoginUser where UserId = " + id;
DBHelper.ExectuteCommand(sql);
}
}
}
584180865也许我能帮到你。
1349189602,我看看
986868488,发来我看看
137254065