Returning the SqlDataReader - c#

I am trying to either pass a reader by reference or to have one returned. And I am having issues with it on the return.
public static SqlDataReader GetSql(string businessUnit, string taskId)
{
const string connstring = "Connection string";
SqlConnection conn = new SqlConnection(connstring);
SqlCommand command = new SqlCommand();
SqlDataReader reader;
try
{
conn.Open();
command.Connection = conn;
command.CommandType = CommandType.Text;
command.CommandText =
"SELECT * FROM Audits WHERE BusinessUnit = #BU AND TaskID = #TID";
command.Parameters.AddWithValue("#BU", businessUnit);
command.Parameters.AddWithValue("#TID", taskId);
return reader = command.ExecuteReader(CommandBehavior.CloseConnection);
}
catch (Exception ex)
{
return null;
}
finally
{
conn.Close();
}
}
SqlDataReader reader = QaqcsqlLib.GetSql("job", "Task1");
if (reader.HasRows)
{
while (reader.Read())
MessageBox.Show(reader[0].ToString());
}
but I get the following error
Invalid attempt to call HasRows when reader is closed.
Any Ideas?

This is the problem:
finally
{
conn.Close();
}
You're closing the connection before the method returns. The reader isn't going to be able to function without an open connection.
(It's not clear why you've got the reader variable at all, given that you only use it when returning.)
Returning a SqlDataReader in a method which itself opens the connection is generally tricky - because it means you don't have a nice way of closing the connection. Better would be to let the caller pass in the connection, at which point you can have:
using (var connection = new SqlConnection(...))
{
using (var reader = QaqcsqlLib.GetSql(connection, "job", "Task1"))
{
// Use the reader here
}
}
EDIT: As noted by Scott, your use of CommandBehavior.CloseConnection would allow closing the reader to close the connection. However, it makes other things trickier. For example, you'd have to dispose of the connection if an exception occurs (because then the caller won't have a chance), but not otherwise - I still prefer my approach.

John is right about why you are having the problem but you don't need to pass in a connection.
I can see that you are already using the SqlCommand.ExecuteReader(CommandBehavior) overload when you start your reader and passing in CommandBehavior.CloseConnection. However the thing you are doing wrong is you are never disposing of the reader that is returned from your function. Remove the finally block then wrap your returned reader in a using block. This will close the underlying connection for you when you exit the block (becuse you passed in CommandBehavior.CloseConnection)
using(SqlDataReader reader = QaqcsqlLib.GetSql("job", "Task1"))
{
while (reader != null && reader.Read()) //Added null check as your GetSql could return null.
MessageBox.Show(reader[0].ToString());
}
I also stripped out reader.HasRows because it is unnessasary. If no results where returned the first call to reader.Read() will return false and the code inside the while loop will never execute.
You still need to close the connection when a exception occurs but you can just move the close from the finally in to the catch.
catch (Exception ex)
{
conn.Dispose(); //Disposing closes the connection.
return null;
}

you can try follow the next example http://msdn.microsoft.com/en-us/library/haa3afyz.aspx .
You shouldn't call to close method before to use your reader.

Jon Skeet and Scott Chamberlain are both correct. If you wish to keep with your way of structuring the code (as opposed to Jon Skeet's approach), you will need to modify your code so that the connection is closed should an error occur while executing the SqlCommand.
public static SqlDataReader GetSql(string businessUnit, string taskId)
{
const string connstring = "Connection string";
SqlConnection conn = null;
SqlCommand command = null;
SqlDataReader reader = null;
try
{
conn = new SqlConnection(connstring);
command = new SqlCommand();
command.Connection = conn;
command.CommandType = CommandType.Text;
command.CommandText = "SELECT * FROM Audits WHERE BusinessUnit = #BU AND TaskID = #TID";
command.Parameters.AddWithValue("#BU", businessUnit);
command.Parameters.AddWithValue("#TID", taskId);
conn.Open();
reader = command.ExecuteReader(CommandBehavior.CloseConnection);
conn = null;
return reader;
}
catch (Exception ex)
{
return null;
}
finally
{
if (conn != null) conn.Dispose();
if (command != null) command.Dispose();
}
}

Related

Having trouble with: The connection was not closed. The connection's current state is open. - SQL Server & C#

I'm currently working on the login form of a school management system. The thing is that when I try to log in, I get an error:
System.InvalidOperationException: The connection was not closed. The connection's current state is open
It says that the error is on the 30th line of code but I can't seem to find a way to solve it.
Here's the code of the method in which the error occurs:
public void LoginTeacher()
{
try
{
command = new SqlCommand("TeacherLogin", connection);
command.CommandType = CommandType.StoredProcedure;
connection.Open(); // This is the 30th line.
command.Parameters.AddWithValue("#username", Txt_User.Text);
command.Parameters.AddWithValue("#password", Txt_Pass.Text);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
TeacherDash teacherDash = new TeacherDash();
this.Hide();
teacherDash.lblusertype.Text = dataReader[1] + " " + dataReader[2].ToString();
teacherDash.ShowDialog();
this.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
connection.Close();
}
}
Immediately after that error is shown there is another one that says:
System.InvalidOperationException: Invalid attempt to call CheckDataIsReady when reader is closed
and points to line 71 which is the following:
public void Login()
{
try
{
command = new SqlCommand("SP_USER_LOGIN", connection);
command.CommandType = CommandType.StoredProcedure;
connection.Open();
command.Parameters.AddWithValue("#user", Txt_User.Text);
command.Parameters.AddWithValue("#pass", Txt_Pass.Text);
SqlDataReader dataReader = command.ExecuteReader();
if (dataReader.Read())
{
LoginTeacher();
if (dataReader[10].Equals("Admin"))
{
AdminDash adminDash = new AdminDash();
this.Hide();
adminDash.lblusertype.Text = dataReader[1] + " " + dataReader[2].ToString();
adminDash.ShowDialog();
this.Close();
}
There's more code after that but I don't find it relevant since it's the same thing but with the different type of users.
Thanks in advance!
You could try changing your TeacherLogin() method to something like the following:
public void TeacherLogin()
{
try
{
using(SqlConnection con = new SqlConnection("connection string"))
{
using(SqlCommand cmd = new SqlCommand("TeacherLogin"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#username", Txt_User.Text);
cmd.Parameters.AddWithValue("#password", Txt_Pass.Text);
cmd.Connection = con;
con.Open();
using(SqlDataReader dr = cmd.ExecuteReader())
{
while(dr.Read())
{
TeacherDash teacherDash = new TeacherDash();
this.Hide();
teacherDash.lblusertype.Text = string.Format("{0} {1}", dr[1], dr[2]);
teacherDash.ShowDialog();
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
There's no need to use finally{} to close the connection as its all wrapped in a using() block, it will close and dispose on its own when the code leaves the block. I'd always recommend using SQL connections and commands in this way as not doing so can cause issues by leaving connections open.
Database object need to be closed and disposed. Keeping them local to the method where they are used lets you make sure this happens. using blocks take care of this for you.
I used a DataTable instead of testing with the reader because the connection must remain open as long as the reader is in use. Opening and closing the connection in the briefest possible time is important.
Please don't use .AddWithValue. See http://www.dbdelta.com/addwithvalue-is-evil/
and
https://blogs.msmvps.com/jcoehoorn/blog/2014/05/12/can-we-stop-using-addwithvalue-already/
and another one:
https://dba.stackexchange.com/questions/195937/addwithvalue-performance-and-plan-cache-implications
Here is another
https://andrevdm.blogspot.com/2010/12/parameterised-queriesdont-use.html
Of course you will have to check your database for the real datatypes and field size to have the correct .Add method.
public void LoginTeacher()
{
DataTable dt = new DataTable();
using (SqlConnection cn = new SqlConnection("your connection string"))
using (SqlCommand cmd = new SqlCommand("TeacherLogin", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("#username",SqlDbType.VarChar,100 ).Value = Txt_User.Text;
cmd.Parameters.Add("#password",SqlDbType.VarChar, 100 ).Value =Txt_Pass.Text;
cn.Open();
dt.Load(cmd.ExecuteReader());
} //Your connection and command are both disposed
if (dt.Rows.Count > 0)
{
TeacherDash teacherDash = new TeacherDash();
teacherDash.lblusertype.Text = $"{dt.Rows[0][1]} {dt.Rows[0][2]}";
teacherDash.ShowDialog();
Close();
}
else
MessageBox.Show("Sorry, login failed");
}

NullReferenceException on closing datareader

I am just learning to work with ADO.NET and I seem to have a problem.What I am trying to do is get the data from a table and insert it into a DataTable.Here is my code:
public DataTable GetCategories()
{
SqlConnection connection = null;
SqlDataReader reader = null;
DataTable categories = new DataTable();
try {
connection = new SqlConnection();
connection.ConnectionString = connectionString;
connection.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "GetCategories";
reader = cmd.ExecuteReader();
categories.Columns.Add("Id", typeof(int));
categories.Columns.Add("CategoryName", typeof(int));
while (reader.Read()) {
int categoryId = (int)reader["Id"];
string categoryName = (string)reader["CategoryName"];
categories.Rows.Add(categoryId , categoryName);
}
}catch(Exception e){
DataTable error = new DataTable();
error.Columns.Add("Error");
error.Rows.Add(e.Message);
return error;
}finally{
connection.Close();
reader.Close();
}
return categories;
}
Here is my SQL query :
CREATE PROCEDURE [dbo].[GetCategories]
AS
SELECT Id , CategoryName
FROM Categories
Where I run this method I get back on reader.Close() an exception that says NullRefferenceException.
What am I doing wrong?
EDIT
I just noticed that reader = cmd.ExecuteReader(); throws an InvalidOperationException.Is this because of the query?
The way you have your code written means that if there's an error creating or connecting to the SqlConnection, your finally block will try to close a reader that hasn't been set yet.
Either check for a null value in the finally block or re-structure your code.
The SqlCommand needs access to the SqlConnection object. E.g.:
SqlCommand cmd = new SqlCommand("dbo.GetCategories", connection)
Also, have a look at the using block - it's a better way to structure your data access code.
You need to check the null reference in you finally block:
finally{
connection.Close();
if (reader != null)
reader.Close();
}
If your SqlConnection throws an exception when connection.Open(), the reader is not initialized and its value is null, so you need to check it in your finally block.

Connection is closed exception

I'm new to C# and trying to establish a C# db connection. But I'm getting an exception.
ExecuteReader requires an open and available Connection. The connection's current state is closed.
following is the code
public void executeCommand()
{
SqlConnection con = new SqlConnection(connectionString);
try
{
con.Open();
}
catch (Exception ex)
{
}
SqlDataReader rdr = null;
SqlCommand cmd = new SqlCommand("SELECT * FROM Employees", con);
try
{
rdr = cmd.ExecuteReader();
}
catch (Exception)
{
throw;
}
rdr.Close();
// rdr.Close();
}
and this is my connection string
public static string connectionString =
"Data Source=(local);Initial Catalog=service;User Id='mayooresan';Password='password';";
Thanks for your time in advance.
Most probabbly connection object fails to open a connection, but as you are catching it, you can not figure out the error. To be clear:
try
{
con.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString()); //ADD THIS STRING FOR DEBUGGING, TO SEE IF THERE IS AN EXCEPTION.
}
Hope this helps.
You are catching any exceptions when opening the connection. Most likely the connection is not opening and is throwing an error. Remove the try/catch at the opening of the connection and you will probably see why the connection is not open
You don't close the connection and reader when an exception was raised, therefor you need to use the finally-block of a try/catch or the using-statement which closes implicitely:
using (SqlConnection connection = new SqlConnection(connectionString))
{
using(SqlCommand command = new SqlCommand(queryString, connection)
{
connection.Open();
using(SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
// do something with it
}
}
}
}
Apart from that you should not use empty catch blocks. If a connection cannot be opened, it cannot be used. Then you should log that and throw the exception, but don't act as if nothing had happened.
Try wrapping everything in one try-catch block. As it stands now, if an exception is thrown when you try to open the connection, it will fail silently. Try this code instead:
try
{
SqlConnection con = new SqlConnection(connectionString);
SqlDataReader rdr = null;
SqlCommand cmd = new SqlCommand("SELECT * FROM Employees", con);
rdr = cmd.ExecuteReader();
}
catch(Exception)
{
throw;
}
are you debugging the code?
if not, you wont be able to see the exception because you don't have anything on your catch
Also I suggest this approach to use on your scenario:
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
SqlCommand command = new SqlCommand(queryString, connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(String.Format("{0}", reader[0]));
}
}

All code after SqlDataReader.ExecuteReader skipped

I have the following function:
private void populate()
{
String connectionString = Properties.Settings.Default.Database;
String selectString = "select artikelnummer, omschrijving from Artikels";
SqlDataReader reader = null;
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand(selectString);
reader = command.ExecuteReader();
connection.Open();
int x = 0;
while (reader.Read())
{
String item = String.Empty;
item = Convert.ToString(reader["Artikelnummer"]) + "\t" + Convert.ToString(reader["Omschrijving"]);
x++;
listboxGeselecteerd.Items.Add(item);
}
}
Everything that follows after reader = command.ExecuteReader(); is skipped.
Is there anything I've done wrong?
UPDATE: Moved the connection.Open(); to the right spot. Now, when I reach that line, my output shows Step into: Stepping over non-user code 'System.Data.SqlClient.SqlConnection.Open
And then skips the rest of the function.
My money is on a method higher up in the call stack eating the exception because this should've thrown one because the connection hadn't been opened. That's your biggest problem.
The next problem you have is that your connection is not associated with the SqlCommand so even if it were opened, it wouldn't matter.
Finally, connection.Open(); needs to be before ExecuteReader.
In addition to that, you really ought to be using using blocks.
{
String connectionString = Properties.Settings.Default.Database;
String selectString = "select artikelnummer, omschrijving from Artikels";
SqlDataReader reader = null;
using (SqlConnection connection = new SqlConnection(connectionString))
/* you also need to associate the connection with the command */
using (SqlCommand command = new SqlCommand(selectString, connection))
{
connection.Open();
reader = command.ExecuteReader();
int x = 0;
while (reader.Read())
{
String item = String.Empty;
item = Convert.ToString(reader["Artikelnummer"]) + "\t" + Convert.ToString(reader["Omschrijving"]);
x++;
listboxGeselecteerd.Items.Add(item);
}
}
}
How about some simple "printf"-style debugging and posting the exception you get?
try
{
connection.Open();
...
}
//catch (Exception e)
catch (SqlException e)
{
// at least one of these..
Console.WriteLine(e);
MessageBox.Show(e);
Debug.WriteLine(e);
var inner = e.InnerException;
while (inner != null)
{
//display / log / view
inner = inner.InnerException;
}
}
Given the exception text from the comments (A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll) looks more like the message you'd get just before the real message showed up, I would catch a SqlException and examine the InnerException(s).
I'm surprised it's not throwing an exception, but you need to open the connection before you execute your reader.
You have to open the connection before you try to use it. Move connection.Open() above your command.ExecuteReader() call.
I can only surmise that you need to open your connection before you execute the reader, and that it's being skipping because an exception is being thrown.
You need to open the connection before you call ExecuteReader.
Also, you don't assign your connection to the SqlCommand. You need to do it like this:
using(qlConnection connection = new SqlConnection(connectionString))
{
using(SqlCommand command = new SqlCommand(selectString,connection))
{
connection.Open();
reader = command.ExecuteReader();
// rest of your code.
}
}
private void populate(){
String connectionString = Properties.Settings.Default.Database;
String commandString = "SELECT artikelnummer, omschrijving FROM Artikels";
using (SqlConnection cn = new SqlConnection(connectionString)){
using (SqlCommand cm = new SqlCommand(commandString, cn)){
cn.Open();
SqlDataReader dr = cm.ExecuteReader();
int x = 0;
while (dr.Read()){
String item = String.Empty;
item = Convert.ToString(dr["Artikelnummer"]) + "\t" + Convert.ToString(dr["Omschrijving"]);
x++;
listboxGeselecteerd.Items.Add(item);
}
}
}
}
On a side note, what are you doing with the 'int x'? I see you are incrementing it, but not doing anything with it.

in a "using" block is a SqlConnection closed on return or exception?

First question:
Say I have
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
string storedProc = "GetData";
SqlCommand command = new SqlCommand(storedProc, connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("#EmployeeID", employeeID));
return (byte[])command.ExecuteScalar();
}
Does the connection get closed? Because technically we never get to the last } as we return before it.
Second question:
This time I have:
try
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
int employeeID = findEmployeeID();
connection.Open();
SqlCommand command = new SqlCommand("UpdateEmployeeTable", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("#EmployeeID", employeeID));
command.CommandTimeout = 5;
command.ExecuteNonQuery();
}
}
catch (Exception) { /*Handle error*/ }
Now, say somewhere in the try we get an error and it gets caught. Does the connection still get closed? Because again, we skip the rest of the code in the try and go directly to the catch statement.
Am I thinking too linearly in how using works? ie Does Dispose() simply get called when we leave the using scope?
Yes
Yes.
Either way, when the using block is exited (either by successful completion or by error) it is closed.
Although I think it would be better to organize like this because it's a lot easier to see what is going to happen, even for the new maintenance programmer who will support it later:
using (SqlConnection connection = new SqlConnection(connectionString))
{
int employeeID = findEmployeeID();
try
{
connection.Open();
SqlCommand command = new SqlCommand("UpdateEmployeeTable", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("#EmployeeID", employeeID));
command.CommandTimeout = 5;
command.ExecuteNonQuery();
}
catch (Exception)
{
/*Handle error*/
}
}
Yes to both questions. The using statement gets compiled into a try/finally block
using (SqlConnection connection = new SqlConnection(connectionString))
{
}
is the same as
SqlConnection connection = null;
try
{
connection = new SqlConnection(connectionString);
}
finally
{
if(connection != null)
((IDisposable)connection).Dispose();
}
Edit: Fixing the cast to Disposable
http://msdn.microsoft.com/en-us/library/yh598w02.aspx
Here is my Template. Everything you need to select data from an SQL server. Connection is closed and disposed and errors in connection and execution are caught.
string connString = System.Configuration.ConfigurationManager.ConnectionStrings["CompanyServer"].ConnectionString;
string selectStatement = #"
SELECT TOP 1 Person
FROM CorporateOffice
WHERE HeadUpAss = 1 AND Title LIKE 'C-Level%'
ORDER BY IntelligenceQuotient DESC
";
using (SqlConnection conn = new SqlConnection(connString))
{
using (SqlCommand comm = new SqlCommand(selectStatement, conn))
{
try
{
conn.Open();
using (SqlDataReader dr = comm.ExecuteReader())
{
if (dr.HasRows)
{
while (dr.Read())
{
Console.WriteLine(dr["Person"].ToString());
}
}
else Console.WriteLine("No C-Level with Head Up Ass Found!? (Very Odd)");
}
}
catch (Exception e) { Console.WriteLine("Error: " + e.Message); }
if (conn.State == System.Data.ConnectionState.Open) conn.Close();
}
}
* Revised: 2015-11-09 *
As suggested by NickG; If too many braces are annoying you, format like this...
using (SqlConnection conn = new SqlConnection(connString))
using (SqlCommand comm = new SqlCommand(selectStatement, conn))
{
try
{
conn.Open();
using (SqlDataReader dr = comm.ExecuteReader())
if (dr.HasRows)
while (dr.Read()) Console.WriteLine(dr["Person"].ToString());
else Console.WriteLine("No C-Level with Head Up Ass Found!? (Very Odd)");
}
catch (Exception e) { Console.WriteLine("Error: " + e.Message); }
if (conn.State == System.Data.ConnectionState.Open) conn.Close();
}
Then again, if you work for EA or DayBreak games, you can just forgo any line-breaks as well because those are just for people who have to come back and look at your code later and who really cares? Am I right? I mean 1 line instead of 23 means I'm a better programmer, right?
using (SqlConnection conn = new SqlConnection(connString)) using (SqlCommand comm = new SqlCommand(selectStatement, conn)) { try { conn.Open(); using (SqlDataReader dr = comm.ExecuteReader()) if (dr.HasRows) while (dr.Read()) Console.WriteLine(dr["Person"].ToString()); else Console.WriteLine("No C-Level with Head Up Ass Found!? (Very Odd)"); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); } if (conn.State == System.Data.ConnectionState.Open) conn.Close(); }
Phew... OK. I got that out of my system and am done amusing myself for a while. Carry on.
Dispose simply gets called when you leave the scope of using. The intention of "using" is to give developers a guaranteed way to make sure that resources get disposed.
From MSDN:
A using statement can be exited either when the end of the using statement is reached or if an exception is thrown and control leaves the statement block before the end of the statement.
Using generates a try / finally around the object being allocated and calls Dispose() for you.
It saves you the hassle of manually creating the try / finally block and calling Dispose()
In your first example, the C# compiler will actually translate the using statement to the following:
SqlConnection connection = new SqlConnection(connectionString));
try
{
connection.Open();
string storedProc = "GetData";
SqlCommand command = new SqlCommand(storedProc, connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("#EmployeeID", employeeID));
return (byte[])command.ExecuteScalar();
}
finally
{
connection.Dispose();
}
Finally statements will always get called before a function returns and so the connection will be always closed/disposed.
So, in your second example the code will be compiled to the following:
try
{
try
{
connection.Open();
string storedProc = "GetData";
SqlCommand command = new SqlCommand(storedProc, connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("#EmployeeID", employeeID));
return (byte[])command.ExecuteScalar();
}
finally
{
connection.Dispose();
}
}
catch (Exception)
{
}
The exception will be caught in the finally statement and the connection closed. The exception will not be seen by the outer catch clause.
I wrote two using statements inside a try/catch block and I could see the exception was being caught the same way if it's placed within the inner using statement just as ShaneLS example.
try
{
using (var con = new SqlConnection(#"Data Source=..."))
{
var cad = "INSERT INTO table VALUES (#r1,#r2,#r3)";
using (var insertCommand = new SqlCommand(cad, con))
{
insertCommand.Parameters.AddWithValue("#r1", atxt);
insertCommand.Parameters.AddWithValue("#r2", btxt);
insertCommand.Parameters.AddWithValue("#r3", ctxt);
con.Open();
insertCommand.ExecuteNonQuery();
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message, "UsingTest", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
No matter where's the try/catch placed, the exception will be caught without issues.
Old thread but still relevant. I arrived here looking for a way out of having a using statement inside of a using statement. I am happy with this, notwithstanding any future insightful comments that change my mind. ;) Conversations here helped. Thanks. Simplified for readability -
public DataTable GetExchangeRates()
{
DataTable dt = new DataTable();
try
{
logger.LogInformation($"Log a message.");
string conStr = _config.GetConnectionString("conStr");
using (SqlCommand cmd = new SqlCommand("someProc", new SqlConnection(conStr)))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection.Open();
dt.Load(cmd.ExecuteReader());
}
return dt;
}
catch (Exception ex)
{
logger.LogError(ex, ex.Message);
}
}

Categories