日期:2014-05-19  浏览次数:20863 次

急求用,谁能给太码参考
如何把数据存入数据库中,(如QQ中的用户名,密码怎样存入数据库)



------解决方案--------------------
网上的这样的程序大把,去找一下。
楼主这种情况多看书,光让别人给代码是没有用的。
------解决方案--------------------
private void login_Click(object sender, System.EventArgs e)
{


m_username = username.Text.Trim();
m_password = password.Text.Trim();

string strsel = "select User_Name,User_Password from Info_User where User_Name = ' "+m_username+ " ' and User_Password = ' "+m_password+ " ' ";
// string strsel = "select User_Name,User_Password from Info_User where User_Name = ' "+m_username+ " ' ";
SqlDataReader myDr;
myDr = DB.ExecuteReader(strsel);
if(myDr.Read())
{
this.Hide();
Form3 f3=new Form3();
f3.ShowDialog();

}
else
{
MessageBox.Show( "此用户不存在 ");
}
myDr.Close();


}
------解决方案--------------------
注册:
private void button1_Click(object sender, System.EventArgs e)
{
string m_username = " ";
string m_password = " ";
string m_email = " ";

m_username = textBox3.Text.Trim();
m_password = textBox1.Text.Trim();
m_email = textBox2.Text.Trim();

string strin = "insert into Info_User(User_Name,User_Password,User_Email) values ( ' "+m_username+ " ', ' "+m_password+ " ', ' "+m_email+ " ') ";
string strsel = "select * from Info_User where User_Name = ' "+m_username+ " ' ";
int i = 0;

// t = System.DateTime.Now;

i = DB.ExecuteSelectSql(strsel);
if( i != 0 )
{
MessageBox.Show( "用户名已经存在请从新选择用户名! ");
}
else
if(DB.ExecuteSql(strin) != 0)
{
MessageBox.Show(m_username+ "注册成功!请登陆! ");
Form1 f1=new Form1();
f1.ShowDialog();
}

// DB.ExecuteSql(strin);
// MessageBox.Show(m_username+ "注册成功!请登陆 ");
// Form1 f1=new Form1();
// f1.ShowDialog();
// this.Close();
}
}