ado.cs
来自「一个简单的考生答题系统」· CS 代码 · 共 40 行
CS
40 行
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace Myschool
{
//数据库连接
class Ado
{
private static SqlCommand comm = null;
//建立连接
public static bool select(string name,string pwd) {
int num = 0;
try
{
Connect.conn.Open();//打开连接
comm = Connect.conn.CreateCommand();
comm.CommandText = string.Format("select count(*) from sudent where loginid='{0}' and loginpwd='{1}'", name, pwd);
num = Convert.ToInt32(comm.ExecuteScalar());
}
catch (Exception es)
{
Console.WriteLine(es.Message);
}
finally {
Connect.conn.Close();
}
if (num > 0)
{
return true;
}
else
{
return false;
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?