static void ReadfromSQL(Args _args)//Read Data from SQL
{
System.Data.SqlClient.SqlConnection conn;
System.Data.SqlClient.SqlCommand cmd;
System.Data.SqlClient.SqlDataAdapter da;
System.Data.SqlClient.SqlDataReader dr;
System.Exception netExcepn;
str Empl;
TransDate transDate;
str strQry;
try
{
conn = new System.Data.SqlClient.SqlConnection("server = SERVERNAME; database = DBName; uid = sqluser;pwd= password ; connection timeout=0 ");
strQry = strFmt("SELECT * FROM [DBname].[dbo].[TableName] WHERE importflag = 0");
cmd = new System.Data.SqlClient.SqlCommand(strQry,conn);
conn.Open();
dr = cmd.ExecuteReader();
while(dr.Read())
{
try
{
Empl = dr.get_Item('Employeecode'); // EmployeeCode is the SQL field name
transDate = dr1.get_Item('TransDate');
}
catch (Exception::Error)
{
info("Caught 'Exception::Error'.");
}
}
dr.Close();
conn.Close();
}
catch (Exception::Error)
{
info("Caught 'Exception::Error'.");
}
catch (Exception::CLRError)
{
info("Caught 'Exception::CLRError'.");
netExcepn = CLRInterop::getLastException();
info(netExcepn.ToString());
}
}
{
System.Data.SqlClient.SqlConnection conn;
System.Data.SqlClient.SqlCommand cmd;
System.Data.SqlClient.SqlDataAdapter da;
System.Data.SqlClient.SqlDataReader dr;
System.Exception netExcepn;
str Empl;
TransDate transDate;
str strQry;
try
{
conn = new System.Data.SqlClient.SqlConnection("server = SERVERNAME; database = DBName; uid = sqluser;pwd= password ; connection timeout=0 ");
strQry = strFmt("SELECT * FROM [DBname].[dbo].[TableName] WHERE importflag = 0");
cmd = new System.Data.SqlClient.SqlCommand(strQry,conn);
conn.Open();
dr = cmd.ExecuteReader();
while(dr.Read())
{
try
{
Empl = dr.get_Item('Employeecode'); // EmployeeCode is the SQL field name
transDate = dr1.get_Item('TransDate');
}
catch (Exception::Error)
{
info("Caught 'Exception::Error'.");
}
}
dr.Close();
conn.Close();
}
catch (Exception::Error)
{
info("Caught 'Exception::Error'.");
}
catch (Exception::CLRError)
{
info("Caught 'Exception::CLRError'.");
netExcepn = CLRInterop::getLastException();
info(netExcepn.ToString());
}
}
No comments:
Post a Comment