Hi,
Im new in C#, could you help with my codes.
I need to connect to MS SQL DB (2000) and need to call Stored Proc to return value.
Here is my codes:
private void ExecuteStoredProcs()
{
SqlConnection conn = new SqlConnection(connectionString);
try
{
conn.Open();
SqlCommand getRequestCmd = new SqlCommand(SP, conn);
getRequestCmd.CommandType = CommandType.StoredProcedure;
getRequestCmd.CommandTimeout = commandTimeout;
SqlDataReader getRequestRdr = getRequestCmd.ExecuteReader();
int recordsExtracted = 0;
WriteLog("Getting Data from DB....");
while (getRequestRdr.Read())
{
array = new string[32];
recordsExtracted++;
WriteLog("recordsExtracted = " + recordsExtracted);
for (int x = 0; x < 32; x++)
{
array[x] = getRequestRdr.GetString(x).Trim();
(DEBUG_MODE == 1)
WriteLog("array[" + x + "] = " + array[x] + " (is not null)");
}
}
ProcessFiles();
}
catch (Exception e)
{
WriteLog("Exception error: " + e.Message + "\r\nDetails: " + e.ToString());
}
finally
{
conn.Close();
}
}
=== i didnt encountered error but i think it didnt call the SP since in the logs it only says: 'Getting Data from DB....' and process ended.
Please help me with this.