C#实现oracle数据的查询和删除

peacentury 2012-09-19 07:33:45

public static void doInsertData()
{

string conStr = "provider='OraOleDb.Oracle';Data Source=" +
"(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)))" +
"(CONNECT_DATA =(SERVICE_NAME = test)));User Id=test;Password=test;";

string sqlInsertStr = "insert into SYM_SOFTWARE_COLLECTION" +
"(USERNAME,IP,MAC,YONGYOUSTATUS,YONGYOUEDITION,JINDIESTATUS,JINDIEEDITION,GUANJIAPOSTATUS,GUANJIAPOEDITION,RECORDTIME)" +
"values('" + username + "','" + ip + "','" + mac + "','" + yySta + "','" + yyEdition + "','" + jdSta + "','"
+ jdEdition + "','" + gjpSta + "','" + gjpEdition + "', sysdate )";

String sqlQueryStr = "select * from SYM_SOFTWARE_COLLECTION where USERNAME='test3';";
String sqlDeleteStr = "delete from SYM_SOFTWARE_COLLECTION where USERNAME='test2';";

OleDbConnection sqlCon = new OleDbConnection(conStr);
try
{
sqlCon.Open();
//执行插入没问题,执行查询和删除时都有报错了
//OleDbCommand cmd = new OleDbCommand(sqlInsertStr, sqlCon);

//OleDbCommand cmd = new OleDbCommand(sqlDeleteStr, sqlCon);

OleDbCommand cmd = new OleDbCommand(sqlQueryStr, sqlCon);

cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
sqlCon.Close();
}
}



执行查询和删除时都报错了:ORA-00911: invalid character
刚接触oracle
有点急,求有经验的高手帮忙解答一下,谢谢。。。。
...全文
140 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
peacentury 2012-09-19
  • 打赏
  • 举报
回复
谢谢!!
kawudi2 2012-09-19
  • 打赏
  • 举报
回复
String sqlQueryStr = "select * from SYM_SOFTWARE_COLLECTION where USERNAME='test3';";
String sqlDeleteStr = "delete from SYM_SOFTWARE_COLLECTION where USERNAME='test2';";
双引号里面还有分号。。

111,012

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧