protected void qrjy_Click(object sender, EventArgs e)
{
string tjg = jg.Text;
string tjs = js.Text;
string tjyr = jyrq.Text;
string txj = xj.Text;
string tbh = bh.Text;
string tmc = mc.Text;
string strConn = ConfigurationManager.AppSettings["ctOra"];
OracleConnection cnn = new OracleConnection(strConn);
string sql = "insert into deal (jg,js,jyr,xj,bh,mc) values ('" + tjg + "','" + tjs + "','to_date('" + tjyr + "','yyyy-mm-dd')," + txj + "','" + tbh + "','" + tmc + "')";
OracleCommand cmd = new OracleCommand(sql, cnn);
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
}
提示说cnn.Open();这里没有初始化
------解决方案--------------------------------------------------------
如下修改看看
string strConn = ConfigurationManager.ConnectionStrings["SqlConnStr"].ConnectionString;
类里面是不是有这个东西
请在web.config中配置sqlconnstr:
<connectionStrings>
<add name="SqlConnStr" connectionString="user id=sa;password=sa;initial catalog=test;data source=192.168.1.101" />
</connectionStrings>
------解决方案--------------------------------------------------------
ConfigurationManager.AppSettings["ctOra"] 你配置里的oracle 连接字符串是啥。
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
详细请参考:
http://www.connectionstrings.com/oracle