[C#] MSSQL 접속
// 디비접속 및 프로시저 실행
using System.Data.SqlClient;
public bool updDB(string sSpName, string sParam)
{
//TraceService("start updDB");
SqlConnection Con = new SqlConnection("Server=디비서버아이피;database=디비명;user id=사용자아이디;password=비번");
SqlCommand Cmd = null;
string strSQL;
strSQL = "exec " + sSpName + " '" + sParam + "'";
TraceService("strSQL = [" + strSQL + "]");
try
{
Con.Open();
Cmd = Con.CreateCommand();
Cmd.CommandText = strSQL;
int nRet = Cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
TraceService("Error! updDB db sql err msg = [" + ex.Message + "]");
}
finally
{
if (Cmd != null)
{
Cmd.Dispose();
Cmd = null;
}
if (Con != null)
{
Con.Close();
Con.Dispose();
Con = null;
}
}
//TraceService("end updDB");
return true;
}