19 个解决方案
#1
检查一下吧,看看空格、单引号等
#2
show code
#3
一般都是引号,空格,括号引起的,把执行前的语句打印出来自己看一下就知道了,要细心检查。
#4
try
{}
catch (Exception ex)
{
}
到catch查查看
{}
catch (Exception ex)
{
}
到catch查查看
#5
把你的代码写出来啊.大家看看
#6
.
#7
小问题,仔细检查下代码
#8
从来不存在奇怪的问题.只是错误和精心.
#9
让别人也帮着检查了,没看到有问题!?不知道怎么了
#10
private void AddRecordToDb()
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source="+"F:\\毕业设计\\论文要求\\EnterpriseRiskAssess\\bin\\DebugEnterriseRiskAnalysis.mdb";
conn.Open();
String insertstr = "insert into CompanyRead (Name, nature, size, prospects, Security, Reputation, IndetbRate, CapitalProfitRate, MainTransactionProfitRate, FlowRate, SpeedRate, FunVelocity, Irregularities, Records) VALUSE('"+textBox10.Text+"','"+a+"','"+b+"','"+c+"','"+d+"','"+g+"','"+textBox3.Text+"','"+textBox4.Text+"','"+textBox5.Text+"','"+textBox8.Text+"','"+textBox6.Text+"','"+textBox9.Text+"','"+textBox1.Text+"','"+f+"','"+textBox2.Text+"')";
OleDbDataAdapter myadapter=new OleDbDataAdapter(insertstr,conn);
DataSet ds=new DataSet();
myadapter.Fill(ds,"CompanyRead");
String StrNew = "select * from CompanyRead where Name ='"+textBox10.Text+"'";
OleDbDataAdapter newadapter = new OleDbDataAdapter(StrNew,conn);
DataSet dsNew = new DataSet();
newadapter.Fill(dsNew, "CompanyRead");
DataTable dtNew = dsNew.Tables[0];
if (dtNew.Rows.Count != 0)
{
MessageBox.Show("登入预测记录成功!");
}
else
{
MessageBox.Show("登入预测记录失败!");
}
conn.Close();
}
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source="+"F:\\毕业设计\\论文要求\\EnterpriseRiskAssess\\bin\\DebugEnterriseRiskAnalysis.mdb";
conn.Open();
String insertstr = "insert into CompanyRead (Name, nature, size, prospects, Security, Reputation, IndetbRate, CapitalProfitRate, MainTransactionProfitRate, FlowRate, SpeedRate, FunVelocity, Irregularities, Records) VALUSE('"+textBox10.Text+"','"+a+"','"+b+"','"+c+"','"+d+"','"+g+"','"+textBox3.Text+"','"+textBox4.Text+"','"+textBox5.Text+"','"+textBox8.Text+"','"+textBox6.Text+"','"+textBox9.Text+"','"+textBox1.Text+"','"+f+"','"+textBox2.Text+"')";
OleDbDataAdapter myadapter=new OleDbDataAdapter(insertstr,conn);
DataSet ds=new DataSet();
myadapter.Fill(ds,"CompanyRead");
String StrNew = "select * from CompanyRead where Name ='"+textBox10.Text+"'";
OleDbDataAdapter newadapter = new OleDbDataAdapter(StrNew,conn);
DataSet dsNew = new DataSet();
newadapter.Fill(dsNew, "CompanyRead");
DataTable dtNew = dsNew.Tables[0];
if (dtNew.Rows.Count != 0)
{
MessageBox.Show("登入预测记录成功!");
}
else
{
MessageBox.Show("登入预测记录失败!");
}
conn.Close();
}
#11
insert into (item) values(values) item是14.values是15.我数错了吗?
#12
是的 插多东东进去了
#13
已经改了,我删去'"+f+"',可是还不行,仍说语INSERT INTO句语法有错误
#14
在access中如果字段名与关键字相同就会报“语法错误”,建议用[]将每个字段名括起来
#15
是的哦,item是14个 values是15个,而且那个values还写错了,成valuse了
#16
你还是把sql语句跟踪出来,然后在sql server中运行一下就知道是哪错了。
#17
String insertstr = "insert into CompanyRead (Name, nature, size, prospects, Security, Reputation, IndetbRate, CapitalProfitRate, MainTransactionProfitRate, FlowRate, SpeedRate, FunVelocity, Irregularities, Records) VALUSE('"+textBox10.Text+"','"+a+"','"+b+"','"+c+"','"+d+"','"+g+"','"+textBox3.Text+"','"+textBox4.Text+"','"+textBox5.Text+"','"+textBox8.Text+"','"+textBox6.Text+"','"+textBox9.Text+"','"+textBox1.Text+"','"+f+"','"+textBox2.Text+"')";
中的VALUES写错了
中的VALUES写错了
#18
not "VALUSE"
#19
哈哈,不过这个语句他开始是怎么执行通过的?
#20
#1
检查一下吧,看看空格、单引号等
#2
show code
#3
一般都是引号,空格,括号引起的,把执行前的语句打印出来自己看一下就知道了,要细心检查。
#4
try
{}
catch (Exception ex)
{
}
到catch查查看
{}
catch (Exception ex)
{
}
到catch查查看
#5
把你的代码写出来啊.大家看看
#6
.
#7
小问题,仔细检查下代码
#8
从来不存在奇怪的问题.只是错误和精心.
#9
让别人也帮着检查了,没看到有问题!?不知道怎么了
#10
private void AddRecordToDb()
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source="+"F:\\毕业设计\\论文要求\\EnterpriseRiskAssess\\bin\\DebugEnterriseRiskAnalysis.mdb";
conn.Open();
String insertstr = "insert into CompanyRead (Name, nature, size, prospects, Security, Reputation, IndetbRate, CapitalProfitRate, MainTransactionProfitRate, FlowRate, SpeedRate, FunVelocity, Irregularities, Records) VALUSE('"+textBox10.Text+"','"+a+"','"+b+"','"+c+"','"+d+"','"+g+"','"+textBox3.Text+"','"+textBox4.Text+"','"+textBox5.Text+"','"+textBox8.Text+"','"+textBox6.Text+"','"+textBox9.Text+"','"+textBox1.Text+"','"+f+"','"+textBox2.Text+"')";
OleDbDataAdapter myadapter=new OleDbDataAdapter(insertstr,conn);
DataSet ds=new DataSet();
myadapter.Fill(ds,"CompanyRead");
String StrNew = "select * from CompanyRead where Name ='"+textBox10.Text+"'";
OleDbDataAdapter newadapter = new OleDbDataAdapter(StrNew,conn);
DataSet dsNew = new DataSet();
newadapter.Fill(dsNew, "CompanyRead");
DataTable dtNew = dsNew.Tables[0];
if (dtNew.Rows.Count != 0)
{
MessageBox.Show("登入预测记录成功!");
}
else
{
MessageBox.Show("登入预测记录失败!");
}
conn.Close();
}
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source="+"F:\\毕业设计\\论文要求\\EnterpriseRiskAssess\\bin\\DebugEnterriseRiskAnalysis.mdb";
conn.Open();
String insertstr = "insert into CompanyRead (Name, nature, size, prospects, Security, Reputation, IndetbRate, CapitalProfitRate, MainTransactionProfitRate, FlowRate, SpeedRate, FunVelocity, Irregularities, Records) VALUSE('"+textBox10.Text+"','"+a+"','"+b+"','"+c+"','"+d+"','"+g+"','"+textBox3.Text+"','"+textBox4.Text+"','"+textBox5.Text+"','"+textBox8.Text+"','"+textBox6.Text+"','"+textBox9.Text+"','"+textBox1.Text+"','"+f+"','"+textBox2.Text+"')";
OleDbDataAdapter myadapter=new OleDbDataAdapter(insertstr,conn);
DataSet ds=new DataSet();
myadapter.Fill(ds,"CompanyRead");
String StrNew = "select * from CompanyRead where Name ='"+textBox10.Text+"'";
OleDbDataAdapter newadapter = new OleDbDataAdapter(StrNew,conn);
DataSet dsNew = new DataSet();
newadapter.Fill(dsNew, "CompanyRead");
DataTable dtNew = dsNew.Tables[0];
if (dtNew.Rows.Count != 0)
{
MessageBox.Show("登入预测记录成功!");
}
else
{
MessageBox.Show("登入预测记录失败!");
}
conn.Close();
}
#11
insert into (item) values(values) item是14.values是15.我数错了吗?
#12
是的 插多东东进去了
#13
已经改了,我删去'"+f+"',可是还不行,仍说语INSERT INTO句语法有错误
#14
在access中如果字段名与关键字相同就会报“语法错误”,建议用[]将每个字段名括起来
#15
是的哦,item是14个 values是15个,而且那个values还写错了,成valuse了
#16
你还是把sql语句跟踪出来,然后在sql server中运行一下就知道是哪错了。
#17
String insertstr = "insert into CompanyRead (Name, nature, size, prospects, Security, Reputation, IndetbRate, CapitalProfitRate, MainTransactionProfitRate, FlowRate, SpeedRate, FunVelocity, Irregularities, Records) VALUSE('"+textBox10.Text+"','"+a+"','"+b+"','"+c+"','"+d+"','"+g+"','"+textBox3.Text+"','"+textBox4.Text+"','"+textBox5.Text+"','"+textBox8.Text+"','"+textBox6.Text+"','"+textBox9.Text+"','"+textBox1.Text+"','"+f+"','"+textBox2.Text+"')";
中的VALUES写错了
中的VALUES写错了
#18
not "VALUSE"
#19
哈哈,不过这个语句他开始是怎么执行通过的?