仓鼠爱小鑫鑫
仓鼠爱小鑫鑫
关注数: 1
粉丝数: 1
发帖数: 9
关注贴吧数: 7
各位大神,求解决.net中CSS架构的实例,或者解决下我的问题也行 我主要是实现一下功能: 1.客户端选择IP与端口并验证用户名和密码进行登录: 2.客户端可以上传本地数据库的文件到服务端
各位大神,怎样在Winform中连接sqlite呢?
谁能帮忙看下.net的代码啊,总是出错 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace search { public partial class Frmsearch : Form { public Frmsearch() { InitializeComponent(); } private void Frmsearch_Load(object sender, EventArgs e) { } public void GetScoure(string strSql) { SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=labdata;Integrated Security=True"); con.Open(); SqlCommand com = new SqlCommand(strSql, con); dataGridView1.Rows.Clear(); SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { dataGridView1.Rows.Add(dr[0].ToString(), dr[1].ToString(), dr[2].ToString()); } dr.Close(); con.Close(); } //按取消键则取消 private void btnEsc_Click(object sender, EventArgs e) { ckClass.Checked = false; ckName.Checked = false; ckSID.Checked = false; rdbMan.Checked = false; rdbWoman.Checked = false; } //点击学号则输入学号 private void ckSID_CheckedChanged(object sender, EventArgs e) { if (ckSID.Checked == true) { txtSID.Enabled = true; txtSID.Focus(); } else { txtSID.Text = ""; txtSID.Enabled = false; } } //点击班级则输入班级 private void ckClass_CheckedChanged(object sender, EventArgs e) { if (ckClass.Checked == true) { txtClass.Enabled = true; txtClass.Focus(); } else { txtClass.Text = ""; txtClass.Enabled = false; } } //点击姓名则输入姓名 private void ckName_CheckedChanged(object sender, EventArgs e) { if (ckName.Checked == true) { ckName.Enabled = true; txtName.Focus(); } else { txtName.Text = ""; txtName.Enabled = false; } } // public string strSql;//用于存储SQL语句 public string strSID;//用于存学生编号 public string strName;//用于存储学生姓名 public string strClass;//用于存储学生班级 public string strSex;//用于存储学生姓别 public static int intCount = 0;//控制数据组索引 public string[] strScoure = new string[4]; public int intAdd;//用来判断SQL语句数组 private void btnsure_Click(object sender, EventArgs e) { intCount = 0; if (txtSID.Text != "") { strSID = "学号 like'%" + txtSID.Text + "%'"; strScoure[intCount] = strSID; intCount++; } if (txtName.Text != "") { strName = "姓名 like '%" + txtName.Text + "%' "; strScoure[intCount] = strName; intCount++; } if (txtClass.Text != "") { strClass = "年级 like '%" + txtClass.Text + "%'"; strScoure[intCount] = strClass; intCount++; } //if (rdbMan.Checked == true) //{ // strSex = "学生性别 like '%" + rdbMan.Text + "%'"; // strScoure[intCount] = strSex; // intCount++; //} //if (rdbWoman.Checked == true) //{ // strSex = "学生性别 like '%" + rdbWoman.Text + "%'"; // strScoure[intCount] = strSex; // intCount++; //} for (int i = 0; i < strScoure.Length; i++) { if (strScoure[i] != null) { strSql += strScoure[i]; intAdd++; } }// end switch (intAdd) { case 0: strSql = "select * from Student"; break; case 1: strSql = "select * from Student where " + strScoure[0]; break; case 2: strSql = "select * from Student where " + strScoure[0] + " and " + strScoure[1]; break; case 3: strSql = "select * from Student where " + strScoure[0] + " and " + strScoure[1] + " and " + strScoure[2]; break; //case 4: // strSql = "select * from Student where " + strScoure[0] + " and " + strScoure[1] + " and " + strScoure[2] + " and " + strScoure[3]; // break; } GetScoure(strSql); //MessageBox.Show(strSql); intAdd = 0; intCount = 0; strSql = ""; for (int i = 0; i < strScoure.Length; i++) { if (strScoure[i] != null) { strScoure[i] = null; } }// end } public void getScoure(string str_name) { string txtSID, txtName, txtSex; //连接数据库 SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=labdata;Integrated Security=True"); con.Open(); SqlCommand com = new SqlCommand("select * from Student where 姓名= '" + Name + "'", con); SqlDataReader dr = com.ExecuteReader();// while (dr.Read()) { txtSID = dr[0].ToString(); txtName = dr[1].ToString(); //txtEmpty = dr[2].ToString(); txtSex = dr[2].ToString(); //txtAge = dr[4].ToString(); //txtKnowledge = dr[5].ToString(); //txtTeching = dr[6].ToString(); } dr.Close(); con.Close(); } } }
谁能帮忙写一个FORM中查询代码啊?下面有一写限制条件 数据库地址为本地,表为Student,帮忙写一个,谢谢了
1
下一页