| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 610 人关注过本帖
标题:[求助]用 C#怎么连接用户注册的sql数据库?-->LouisXIV转移
只看楼主 加入收藏
linbin512
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-2-13
收藏
 问题点数:0 回复次数:0 
[求助]用 C#怎么连接用户注册的sql数据库?-->LouisXIV转移

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace SStiForum
{
/// <summary>
/// Register 的摘要说明。
/// </summary>
public class Register : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.TextBox TextBox5;
protected System.Web.UI.WebControls.RadioButton RadioButton1;
protected System.Web.UI.WebControls.RadioButton RadioButton2;

public SqlConnection MyConn;
public SqlDataReader dr;
public string PassCheck;
public string UserName;
public string Pass;
public string QQ;
public string mail;
public string face;
public string HeadImg;
public string sex;
public int check=0;
public string Action;
public HttpCookie readcookie;
protected System.Web.UI.WebControls.Button submit;
protected System.Web.UI.WebControls.Button clear;
public string Postuser;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Action=Request.QueryString["Action"].ToString();
UserName=Request.QueryString["UserName"].ToString();
if (UserName=="")
{
UserName=UserCheck();
if (UserName=="Wrong"&&Action!="reg")
{
Response.Redirect("Exception.aspx?ms=1");
}
}
}
public string UserCheck()
{
if (Request.Cookies["Cookie"]==null)
{
return("Wrong");
}
else
{
readcookie = Request.Cookies["Cookie"];
if (readcookie.Values["UserName"].ToString()!=null)
{

Postuser= readcookie.Values["UserName"].ToString();
Pass= readcookie.Values["Pass"].ToString();
return(Postuser);
}
else
{
return("Wrong");
}
}

}

private void Button2_Click(object sender, System.EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
}

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}


private void sumbit_Click(object sender, System.EventArgs e)
{
UserName=TextBox1.Text;
Pass=TextBox2.Text;
PassCheck=TextBox3.Text;
QQ=TextBox4.Text;
mail=TextBox5.Text;
if( RadioButton1.Checked == true )
sex="1";
else
sex="2";

face=Request.Form["HeadImage"];
HeadImg=face;
HeadImg=HeadImg.Replace("'","''");


if (PassCheck!=Pass)
{
Response.Redirect("Exception.aspx?ms=12");
}
if (UserName==""||Pass=="")
{
Response.Redirect("Exception.aspx?ms=11");
}

CMySql SP_ChekUserName = new CMySql();//错误
dr = SP_ChekUserName.CheckUserName(UserName);

while(dr.Read())
{
check=1;
}
dr.Close();

if (check==0)
{
CMySql SP_AddUser = new CMySql();//错误
SP_AddUser.AddUser(UserName,Pass,Int32.Parse
(QQ),mail,Int32.Parse(sex), HeadImg);
}

if (check==1)
{
Response.Redirect("exception.aspx?ms=14");
}
else
{
Response.Redirect("Login.aspx");
}
}
}
}

搜索更多相关主题的帖子: 用户 sql LouisXIV 数据库 
2006-06-03 09:59
快速回复:[求助]用 C#怎么连接用户注册的sql数据库?-->LouisXIV转移
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027121 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved