dim dt as new datatalbe() dim ds as new dataset() dim myconn as sqlconnection=new sqlconnection("server=localhost;uid=sa;pwd=123456;database=pub") dim mycomm as sqlcommand=new sqlcommand("select * from users", myconn)dim dr as sqldatareader dr.fill(dt) ds.tables.add(dt) if ds.tables(0).rows.count<=0 then ..... else ................... end if
1 创建一个工程(实际上你已经创建了)
2 在工程中添加一个新的Windows窗体(Windows Form),命名为loginForm.cs(也可以改变)
3 在你原来工程的cs文件(主Form)中找到如下部分
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
改为
[STAThread]
static void Main()
{
Application.Run(new loginForm());
Application.Run(new Form1());
}
然后在你的loginForm.cs中修改 loginForm_Closed 函数
加入你的判断条件:(比如是OK或者Cancel,还要看CheckLogin()是否为true之类)
反正如果不满足你的条件则可用
Application.Exit()退出应用程序
dim ds as new dataset()
dim myconn as sqlconnection=new sqlconnection("server=localhost;uid=sa;pwd=123456;database=pub")
dim mycomm as sqlcommand=new sqlcommand("select * from users", myconn)dim dr as sqldatareader
dr.fill(dt)
ds.tables.add(dt)
if ds.tables(0).rows.count<=0 then
.....
else
...................
end if