拉控件※编代码※数据库验证的programer们看过来!
我是从dataset拉出一些控件 绑定到 form 的
可是经常出一些 类似的 找不到关于........定义的 问题
我是觉得 肯定有共同之处,但找不到 症结所在,有哪位师傅指导一下?
多谢!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace GettingData
{
public partial class GettingData : Form
{
public GettingData()
{
InitializeComponent();
}
private void GettingData_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“dataSet2.FPAX_USERS”中。您可以根据需要移动或移除它。
this.fPAX_USERSTableAdapter.Fill(this.dataSet2.FPAX_USERS);
// TODO: 这行代码将数据加载到表“dataSet1.WORKLIST”中。您可以根据需要移动或移除它。
this.wORKLISTTableAdapter.Fill(this.dataSet1.WORKLIST);
}
private void bindingNavigatorPositionItem_Click(object sender, EventArgs e)
{
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void wORKLISTBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
}
private void pATIENT_IDTextBox_TextChanged(object sender, EventArgs e)
{
}
private void fillToolStripButton_Click(object sender, EventArgs e)
{
try
{
this.wORKLISTTableAdapter.Fill(this.dataSet1.WORKLIST);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
private void professionLabel_Click(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void pATIENT_IDLabel_Click(object sender, EventArgs e)
{
}
private void pATIENT_NAMELabel_Click(object sender, EventArgs e)
{
}
private void nAME_PHONETICLabel_Click(object sender, EventArgs e)
{
}
private void professionTextBox_TextChanged(object sender, EventArgs e)
{
}
private void nAME_PHONETICTextBox_TextChanged(object sender, EventArgs e)
{
}
private void pATIENT_NAMETextBox_TextChanged(object sender, EventArgs e)
{
}
//关键是以下登陆到数据库的验证问题
private void 登录_Click(object sender, EventArgs e)
{
string user =this.user_name.Text.Trim();
// 出错之处:“GettingData.GettingData”并不包含“user_name”的定义
string pwd = this.txtPWD.Text.Trim();
//“GettingData.GettingData”并不包含“txtPWD”的定义
SqlConnection con = Common.CreateCon();
当前上下文中不存在名称“Common”
//
string strcon = "select top 1 * from Admin where Uname= ' "+user+ " ' ";
SqlCommand cmd = new SqlCommand(strcon, con);
SqlDataReader sdr;
try
{
con.Open();
sdr = cmd.ExecuteReader();
sdr.Read();
if(sdr.HasRows)
{
if(pwd==sdr[ "Upwd "].ToString())
{
this.Islogin = true;
//“GettingData.GettingData”并不包含“Islogin”的定义
this.Close();
}
else{
MessageBox.Show( "帐号或密码错误! ");}
}
else{
MessageBox.Show( "帐号或密码错误! ");}
}
catch (Exception ex)
{
string exm=ex.Message;
MessageBox.Show( "出现异常,无法登陆! ");
}
finally
{
con.Close();
}
}
private void user_nameTextBox_TextChanged(object sender, EventArgs e)
{
}
private void user_nameLabel_Click(object sender, EventArgs e)
{
}
}
}
[解决办法]
帮顶了 !