散分30请教提交数据库问题!!
private void Op_tj_Click(object sender, System.EventArgs e)
{
int Op_p = int.MinValue;
try
{
.....
.....
.....
.....
Op_p = cmd.ExecuteNonQuery();
}
catch
{
出现错误弹出对话框告知“提交失败”
}
if( Op_p > -1)
{
提交完成时候弹出对话框“提交成功”
}
应该如何编写这段程序 请高手指教一下!
}
------解决方案--------------------int Op_p = int.MinValue;
string strConn = "data source=数据库名;uid=用户名;pwd =密码 ";
OracleConnection conn = new OracleConnection(strConn);
string strSQL = string.Empty;
StringBuilder sb = new StringBuilder();
sb.Append( "SELECT ")
.Append( )
.........
strSQL = sb.ToString();
try
{
conn.Open();
OracleCommand cmd = new OracleCommand(strSQL,conn);
Op_p = cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
Response.Write( " <script> alert( '提交失败 '); </script> ");
}
finally
{
if(this.conn.State == ConnectionState.Open)
{
conn.Close();
}
}
if( Op_p > -1)
{
Response.Write( " <script> alert( '提交成功 '); </script> ");
}
没有测试过。不过 应该可以实现
------解决方案--------------------是上面几些情况吗.
如果问题解决了欢迎帮忙, 看看我的求救, 谢谢:> 征名散分: http://community.csdn.net/Expert/TopicView1.asp?id=5405222