c#怎么连接oracle数据库
1个回答
展开全部
通过ADO.Net连接数据库:
Oracle连接字符串:
string connStr = "Data Source=数据库服务名;user=用户名;password=密码";
try
{
using (OracleConnection oraconn = new OracleConnection(strConn))
{
oraconn.Open();
using (OracleCommand oracmd = oraconn.CreateCommand())
{
oracmd.CommandText = sql语句;
oracmd.ExecuteNonQuery()或oracmd.ExecuteScalar();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Oracle连接字符串:
string connStr = "Data Source=数据库服务名;user=用户名;password=密码";
try
{
using (OracleConnection oraconn = new OracleConnection(strConn))
{
oraconn.Open();
using (OracleCommand oracmd = oraconn.CreateCommand())
{
oracmd.CommandText = sql语句;
oracmd.ExecuteNonQuery()或oracmd.ExecuteScalar();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询