visual studio 2005下C#编程

来源:百度知道 编辑:UC知道 时间:2024/07/02 05:28:22
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 Login
{
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
Conn con = new Conn(this.textBox1.Text, this.textBox2.Text, this.textBox3.Text, this.textBox4.Text);
SqlConnection SqlConnection = con.creatConn();
SqlCommand cmd=new SqlCommand("SELECT COUNT(*)FROM Users WHERE UserName='''+this.textBox5.Text+'''and Password='''+this.textBox.Text+'''",SqlConnection );
string t=cmd.ExecuteScalar().ToString();
cmd.Connection.Close();
if(t=="1")
{
this.Visible =false

第一个问题:看看你的那个Conn类的命名空间跟当前类的命名空间是不是一样的,如果不是一样的就要改成一样的
第二个问题:Login应该是窗体类的名称吧,但Login是命名空间,这样的话编译时被当做命名空间使用,所以报错的,要么把命名空间改下,要么把类名改下

Conn con = new Conn(this.textBox1.Text, this.textBox2.Text, this.textBox3.Text, this.textBox4.Text);
Conn是什么?你没有定义 也不懂你怎么写的

namespace Login//命名空间
Login login=new Login();
应该是 命名空间的冲突
是不是有个Login窗体
实例化的时候 发生冲突 把命名空间修改下