FileNotFoundException: Could not load file or assembly 'System.Data.SqlClient, Version=0.0.0.0, Cult

public void makenewuser()
{
string constring = "Data Source =LAPTOP-3KI3JMHO; Initial Catalog = Stormz; Integrated Security = True";
using (SqlConnection con = new SqlConnection(constring))
try
{
con.Open();
SqlCommand com = new SqlCommand("INSERT INTO users('" + firstname + "','" + lastname + "','" + email + "','" + password + "','" + country + "', '" + city + "')", con);
com.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}

}
public void makenewuser()
{
string constring = "Data Source =LAPTOP-3KI3JMHO; Initial Catalog = Stormz; Integrated Security = True";
using (SqlConnection con = new SqlConnection(constring))
try
{
con.Open();
SqlCommand com = new SqlCommand("INSERT INTO users('" + firstname + "','" + lastname + "','" + email + "','" + password + "','" + country + "', '" + city + "')", con);
com.ExecuteNonQuery();
con.Close();
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}

}
This is the method giving the issue. Before I was using System.Data.SqlClient but it gave me an error so I switched to Microsoft.Data.SqlClient now im getting this issue. I downloaded the package and it exist so im not to sure why it keeps throwing an the exception in the title.
7 Replies
Buddy
Buddy7d ago
Unrelated to your issue, but still a very big part, please don't do this
"INSERT INTO users('" + firstname + "','" + lastname + "','" + email + "','" + password + "','" + country + "', '" + city + "'
"INSERT INTO users('" + firstname + "','" + lastname + "','" + email + "','" + password + "','" + country + "', '" + city + "'
$sqlinjection
MODiX
MODiX7d ago
Always parametrize queries! Do not concatenate the query, like in this example:
// Do NOT do this
string query = "SELECT * FROM users WHERE username='" + UserName + "';";
...
// Do NOT do this
string query = "SELECT * FROM users WHERE username='" + UserName + "';";
...
Instead, always parameterize your queries. Look up the documentation for your database library. If you are using System.Data.SqlClient, refer to this example.
Imgur
canton7
canton77d ago
That's a very important point, please don't ignore that
[ECH]JamHighlight
Hm when I saw it on sparknotes I didnt see anyone disapproving Alr thx Ok so it appears to be compatiability issues.
[ECH]JamHighlight
Ok so if you encounter this issue future viewers, you are mostly likely using a sql connection package that is not compatible with your net project.
Unknown User
Unknown User6d ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?