| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3431 人关注过本帖
标题:在 System.ArgumentException 中第一次偶然出现的“System.Data.dll”类型的 ...
只看楼主 加入收藏
口水恩怨
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2012-10-7
结帖率:33.33%
收藏
已结贴  问题点数:18 回复次数:4 
在 System.ArgumentException 中第一次偶然出现的“System.Data.dll”类型的异常
代码如下:
using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = "myQQ";
           
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            MessageBox.Show("没睡醒呢吧您类!还真当我是万能的啦!");
        }
        
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox2.Text == "" || comboBox1.Text == "")
                MessageBox.Show("账号或密码不能为空!");
            else
            {
                string connectionString = String.Format("Data Source=localhost;Iniyial Catalog=QQ;Integrated Security=true");
                //创建connection对象
                SqlConnection conn = new SqlConnection(connectionString);
                //编写sql语句
                string sql = string.Format("Select 账号,密码 from 注册表 ");
                //创建command对象
                SqlCommand command = new SqlCommand(sql, conn);
                //打开连接
                conn.Open();
                //创建sqldatareader对象用来读取数据库内容
                SqlDataReader read = command.ExecuteReader();
                //执行查询(这里的查询为把数据库中为fontname的列的所有值加入textBox1中)
                if (comboBox1.Text == read["账号"].ToString())
                {
                    if (textBox2.Text == read["密码"].ToString())
                    {
                        登陆成功 dl = new 登陆成功();
                        dl.Show();
                        this.Close();
                    }


                }
                else
                    MessageBox.Show("密码错误!");
                //关闭对象和数据库连接

                read.Close();
                conn.Close();
            }


           
        }
    }
}
搜索更多相关主题的帖子: 异常 public private 
2012-12-22 19:42
hjywyj
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:3
帖 子:1114
专家分:2611
注 册:2010-4-14
收藏
得分:9 
  if (comboBox1.Text == read["账号"].ToString())
=>
 if (read.Read()&&comboBox1.Text.Trim() == read["账号"].ToString().Trim())
2012-12-22 19:49
口水恩怨
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2012-10-7
收藏
得分:0 
回复 2楼 hjywyj
哥,恕小弟愚昧,没看懂
2012-12-22 21:22
ZWYyj
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:9
帖 子:124
专家分:587
注 册:2012-8-10
收藏
得分:9 
请你把出错的代码行指出来吧
2012-12-29 16:34
frforum
Rank: 1
等 级:新手上路
帖 子:2
专家分:1
注 册:2012-12-24
收藏
得分:0 
2楼正解!
2013-01-02 19:26
快速回复:在 System.ArgumentException 中第一次偶然出现的“System.Data.dll” ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012924 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved