I have a Winform program that has a lot of SqlConnection function that interacts with a local MDF database.
This is how I create the connection string:
String dbPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Bot\DB\BotDB.mdf";
String con = String.Format("Data Source=(LocalDB)\\v11.0;AttachDbFilename=\"{0}\";Integrated Security=True;Connection Timeout=10;", dbPath);
return con;
And this is one of many calls i made to the Database:
public bool InsertNewUserToTable(String username)
{
using (SqlConnection con = new SqlConnection(DataBase.GetConString()))
{
con.Open();
String query = @"INSERT INTO dbo.Users(username) VALUES(@username);";
using (SqlCommand cmd = new SqlCommand(query, con))
{
cmd.Parameters.AddWithValue("@username", username);
int count = cmd.ExecuteNonQuery();
con.Close();
return (count == 0) ? false : true;
}
}
}
I have more methods like this one that deletes, update, insert data from the Database.
The program working with multithread that access the database in this way.
The problem is that sometimes I get a crash error(on publish mode):
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: Bot.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 5cbce361
Problem Signature 04: System.Data
Problem Signature 05: 4.7.2623.0
Problem Signature 06: 5a1f67d8
Problem Signature 07: 1a55
Problem Signature 08: 5e
Problem Signature 09: System.Data.SqlClient.Sql
OS Version: 6.3.9600.2.0.0.272.7
Locale ID: 1033
Additional Information 1: 4e4b
Additional Information 2: 4e4be395a3a959f2a72f71ab9c9204ab
Additional Information 3: 783e
Additional Information 4: 783ea04fb900812a4241ad9aeb1b45b6
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=280262
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
I tried to find a way to find the specific Exception with this information: https://stackoverflow.com/a/4053325/679099
But I wasn't able to find any specific thing that crash my application.
Any idea what can be the issue? Something else that I'm missing?