关于Oracle.managedDataAccess.dll连接数据库问题
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.ManagedDataAccess.Client;
using Oracle.ManagedDataAccess.Types;
namespace WinformDeom
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
OracleConnection conn = null;
conn = new OracleConnection("User Id=GMGMARS7;Password=GMGMARS7;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.166.22)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MARS)));"
);
if (conn.State == System.Data.ConnectionState.Closed)
try
{
conn.Open();
}
catch (Exception ex)
{
conn.Close();
conn.Dispose();
MessageBox.Show(ex.Message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
try
{
string v_sql;
v_sql = @"select * from MARSTOOLS_3_RPH3 t where t.账期 = " + this.textBox1.Text;
DataSet dsTmp = OracleHelper.ExecuteDataset(conn, CommandType.Text, v_sql);
if (ds.Tables.Contains("Ac"))
ds.Tables.Remove("Ac");
DataTable Dc = dsTmp.Tables["table"].Copy();
Dc.TableName = "Ac";
ds.Tables.Add(Dc);
this.dataGridView1.AutoGenerateColumns = true;
this.dataGridView1.DataSource = ds.Tables["Ac"];
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
有没高手指点一下,什么环节能够引起数据库连接问题?这个简单的示例之前是可以运行的,这两周再打开的时候连接就有异常了,再此谢谢大家了。