C# 连接ACCESS,运行时提示“标准表达式中数据类型不匹配。” 新手求指教,详细点,谢谢。
代码string恶化=this.comboBox1.Text;string改善=this.comboBox2.Text;if(改善==""||恶化==""){Messag...
代码
string 恶化 = this.comboBox1.Text;
string 改善 = this.comboBox2.Text;
if (改善 == "" || 恶化 == "")
{
MessageBox.Show("请正确选择参数");
}
string a1 = Application.StartupPath + @"\\D:\Backup\我的文档\My Documents\Favorites\研究生阶段\科研\TRIZ\48参数矛盾矩阵.mdb";
OleDbConnection con = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0; Data Source =D:\Backup\我的文档\My Documents\Favorites\研究生阶段\科研\TRIZ\48参数矛盾矩阵.mdb ");
OleDbCommand acommand = new OleDbCommand("select * from 48参数矛盾矩阵 where ID = ' + 改善 + '", con);
con.Open();
//创建datareader 对象来连接到表单
OleDbDataReader areader = acommand.ExecuteReader();
//读取数据
areader.Read();
char[] c = 恶化.ToCharArray(); //将读取到的字符串转换成字符数组
char c1 = c[0]; //取出需要的字符
char c2 = c[1];
int num1 = c1 - 48; //将所需字符强制转换成其ASCLL码值,然后转换成所需的整型
int num2 = c2 - 48;
int num = num1 * 10 + num2;
string du = areader.GetString(num).ToString();
areader.Close();
if (du == "0")
{
MessageBox.Show("参数选择错误");
}
else
{
string[] split = du.Split(','); //使用Split拆分字符串并放置在split[]数组中
int n = split.Length;
int i;
for (i = 0; i < n; i++)
{
string dudu = split[i];
char[] d = dudu.ToCharArray();
int d1 = d[0] - 48;
int d2, d3;
if (d.Length >= 2)
{
d2 = d[1] - 48;
d3 = d1 * 10 + d2;
}
d3 = d1;
OleDbCommand acommand2 = new OleDbCommand("select * from 发明原理 where ID = " + d3 + "", con);
OleDbDataReader areader2 = acommand2.ExecuteReader();
areader2.Read();
string duu1 = areader2.GetString(1).ToString();
areader2.Close();
if (i == 0)
{
radioButton3.Text = duu1;
this.radioButton3.Visible = true;
}
else if (i == 1)
{
radioButton4.Text = duu1;
this.radioButton4.Visible = true;
}
}
con.Close();
} 展开
string 恶化 = this.comboBox1.Text;
string 改善 = this.comboBox2.Text;
if (改善 == "" || 恶化 == "")
{
MessageBox.Show("请正确选择参数");
}
string a1 = Application.StartupPath + @"\\D:\Backup\我的文档\My Documents\Favorites\研究生阶段\科研\TRIZ\48参数矛盾矩阵.mdb";
OleDbConnection con = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0; Data Source =D:\Backup\我的文档\My Documents\Favorites\研究生阶段\科研\TRIZ\48参数矛盾矩阵.mdb ");
OleDbCommand acommand = new OleDbCommand("select * from 48参数矛盾矩阵 where ID = ' + 改善 + '", con);
con.Open();
//创建datareader 对象来连接到表单
OleDbDataReader areader = acommand.ExecuteReader();
//读取数据
areader.Read();
char[] c = 恶化.ToCharArray(); //将读取到的字符串转换成字符数组
char c1 = c[0]; //取出需要的字符
char c2 = c[1];
int num1 = c1 - 48; //将所需字符强制转换成其ASCLL码值,然后转换成所需的整型
int num2 = c2 - 48;
int num = num1 * 10 + num2;
string du = areader.GetString(num).ToString();
areader.Close();
if (du == "0")
{
MessageBox.Show("参数选择错误");
}
else
{
string[] split = du.Split(','); //使用Split拆分字符串并放置在split[]数组中
int n = split.Length;
int i;
for (i = 0; i < n; i++)
{
string dudu = split[i];
char[] d = dudu.ToCharArray();
int d1 = d[0] - 48;
int d2, d3;
if (d.Length >= 2)
{
d2 = d[1] - 48;
d3 = d1 * 10 + d2;
}
d3 = d1;
OleDbCommand acommand2 = new OleDbCommand("select * from 发明原理 where ID = " + d3 + "", con);
OleDbDataReader areader2 = acommand2.ExecuteReader();
areader2.Read();
string duu1 = areader2.GetString(1).ToString();
areader2.Close();
if (i == 0)
{
radioButton3.Text = duu1;
this.radioButton3.Visible = true;
}
else if (i == 1)
{
radioButton4.Text = duu1;
this.radioButton4.Visible = true;
}
}
con.Close();
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询