My friend and I are making an application using c#, WPF and visual studio. We've made a login feature using MS SQL Server and the database is on my computer. When I share the source code to my friend and he opens it in Visual Studio (on his PC) he can't login like I can. Anytime he presses the "Login" button the program instantly crashes, not even giving any errors.
On my PC when I click the "Login" button it moves to the next page successfully, so we believe it has something to do with the SQL Database. How can I make it so that it works for his PC too?
Code for Login Button
private void UserSignInBtn_Click(object sender, RoutedEventArgs e)
{
SqlConnection sqlCon = new SqlConnection(connectionString);
try
{
if (sqlCon.State == ConnectionState.Closed)
{
sqlCon.Open();
string query = "SELECT COUNT (1) FROM tblSignUP WHERE StudentName=@StudentName AND Password=@Password";
SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
sqlCmd.CommandType = CommandType.Text;
sqlCmd.Parameters.AddWithValue("@StudentName", tbID.Text);
sqlCmd.Parameters.AddWithValue("@Password", PB.Password);
int count = Convert.ToInt32(sqlCmd.ExecuteScalar());
if (count == 1)
{
// Custom Message Box and Dim Effect
var jim = new Dim();
jim.Show();
this.Effect = new BlurEffect();
var lsmb = new Custom_MessageBoxes.LoginSuccessfulMsgBox();
lsmb.ShowDialog();
this.Effect = null;
jim.Close();
var User_Homepage = new User_Homepage();
NavigationService.Navigate(User_Homepage);
}
else
{
// Custom Message Box and Dim Effect 2
var him = new Dim();
him.Show();
this.Effect = new BlurEffect();
var rmdlgb = new ReturnMessageDialogueBox();
rmdlgb.ShowDialog();
this.Effect = null;
him.Close();
}
}
}
catch(Exception ex)
{
}
finally
{
sqlCon.Close();
}
}```