C#执行的时候有问题
文件:form1.csusing System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace like
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void user_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
data dataconn = new data();
SqlDataReader dr = dataconn.read("select * from kankan where user = '" + this.user.Text + "' and password = '" + this.password.Text + "'");
if (dr.HasRows)
{
dr.Read();
user = dr["user"].ToString();
dr.Close();
MessageBox.Show("已经查到了,这是真的");
}
else
{
MessageBox.Show("哎,你的账号或者是密码有错误哦");
}
dr.Close();
}
}
}
##################################################
文件名:data.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace like
{
class data
{
private string connstr = "server=.;user id=sa;pwd=;database=kankan";
public SqlDataReader read(string str)
{
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand cmd = new SqlCommand(str, conn);
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
}
}
}
执行的时候,提示缺少调试目标,然后就是请生成项目并重试,或者相应的设置outputpath和Assemblyname属性,使其指向目标程序集的正确位置