Witam. Mam taki oto kod:
private void button2_Click(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
SqlConnectionStringBuilder conString = new SqlConnectionStringBuilder();
conString.DataSource = @".\" + comboBox1.SelectedItem.ToString();
conString.InitialCatalog = textBox1.Text; ;
conString.IntegratedSecurity = true;
using (SqlConnection cn = new SqlConnection(conString.ToString()))
{
try
{
cn.Open();
label6.Text = "połączono";
this.label6.ForeColor = Color.Green;
MessageBox.Show("Połączono!", "Komunikat 24Host");
}
catch
{
MessageBox.Show("Wystąpił błąd.");
}
cn.Close();
}
}
if (radioButton2.Checked == true)
{
SqlConnectionStringBuilder conString = new SqlConnectionStringBuilder();
conString.DataSource = @".\" + comboBox1.SelectedItem.ToString();
conString.InitialCatalog = textBox1.Text; ;
conString.IntegratedSecurity = true;
conString.UserID = textBox2.Text;
conString.Password = textBox3.Text;
using (SqlConnection cn = new SqlConnection(conString.ToString()))
{
try
{
cn.Open();
label6.Text = "połączono";
this.label6.ForeColor = Color.Green;
MessageBox.Show("Połączono!", "Komunikat 24Host");
}
catch
{
MessageBox.Show("Wystąpił błąd.");
}
cn.Close();
}
}
}
Podłączenie do bazy przy użyciu jakiegokolwiek hasła i loginu kończy się komunikatem "połączono". Prosiłbym o wskazówki jak to połączenie ustanowić dobrze. A może ktoś zaproponuje inny sposób rozwiązania tego problemu?
pozdrawiam