111,012
社区成员
发帖
与我相关
我的任务
分享
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();
}
}