只若零星 2015-05-08 01:41 采纳率: 0%
浏览 3438

c#标准表达式中数据类型不匹配

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.OleDb;

namespace login
{
public partial class deleteuser : Form
{
private Int32 current =10001;
string str = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=qyjc.mdb";
public deleteuser()
{
InitializeComponent();
current =10001;
ShowCurrentUser();
}

    private void ShowCurrentUser()
    {
        string command = String.Format("select * from 监察员信息 where zfzh='{0}'",current);
        using (OleDbConnection con = new OleDbConnection(str))
        {
            con.Open();
            OleDbCommand cmd = new OleDbCommand(command, con);
            OleDbDataReader r = cmd.ExecuteReader();//显示问题:标准表达式中数据类型不匹配

            if (r.Read())
            {
                textBox1.Text = r.GetString(0);
                textBox2.Text = r.GetString(1).ToString();
                textBox3.Text = r.GetString(2);
                textBox4.Text = r.GetString(3);
                string xgqx = r.GetString(4);
                if (xgqx == "管理员")
                    checkBox1.Checked = true;
                else checkBox2.Checked = true;
            }
            else
            {
                MessageBox.Show("前面或后面已无数据", "没有数据", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            r.Close();
            con.Close();
        }
    }

    private void deleteuser_Load(object sender, EventArgs e)
    {
        //current = 10001;
        //ShowCurrentUser();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        current--;
        ShowCurrentUser();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        current++;
        ShowCurrentUser();
    }

    private void button3_Click(object sender, EventArgs e)
    {
        string ad_xm = textBox1.Text;
        string ad_zfzh = textBox2.Text;
        string ad_zh = textBox3.Text;
        string ad_pwd = textBox4.Text;

        string ad_qx = "";
        if (checkBox1.Checked) ad_qx += checkBox1.Text;
        if (checkBox2.Checked) ad_qx += checkBox2.Text;
        string command = String.Format("update 监察员信息 set xm='{0}',zh='{1}',pwd='{2}',type='{3}' where zfzh='{4}'", ad_xm, ad_zh, ad_pwd, ad_qx,current );
        string str = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=qyjc.mdb";
        using (OleDbConnection con = new OleDbConnection(str))
        {
            con.Open();
            OleDbCommand cmd = new OleDbCommand(command, con);

            int n = cmd.ExecuteNonQuery();
            if (n <= 0)
            {
                MessageBox.Show("用户信息更新操作失败!", "操作数据库出错", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            con.Close();
        }
    }
}

}

  • 写回答

1条回答 默认 最新

  • frank_20080215 2015-05-08 01:47
    关注

    类定义时,私有变量是这样定义和初始化的:private Int32 current =10001;
    private void ShowCurrentUser()函数中,current没有由整型转换为string,请转换之。

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站