0

Hello guys i've been stuck here for 2 days. I want when i full in my textboxes that the text will go to my database "loonberekening into my table werknemer". But now im getting this

error: An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll

Additional information: Keyword not supported: 'integra‌​ted security'.

and he is ticking this line: SqlConnection cnnLoonberekening = new SqlConnection(database);

Thanks for helping me and here is my code!

private void btnOpslaanwerknemergegevens_Click(object sender, EventArgs e)
    {


        string database = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\gip_stap_2\loonberekening.mdf;Integra‌​ted Security=True;Connect Timeout=30;InitialCatalog=loonberekening";
        string werknemergegevens = "insert into loonberekening.werknemer (naam,voornaam) values ('"+this.txtNaam.Text+"','"+this.txtVoornaam.Text+"');";
        SqlConnection cnnLoonberekening = new SqlConnection(database); 
        SqlCommand scmdLoon = new SqlCommand(werknemergegevens, cnnLoonberekening);
        SqlDataReader check;


        try{
            cnnLoonberekening.Open();
            check = scmdLoon.ExecuteReader();
            MessageBox.Show("Opgeslagen");
            while (check.Read())
            {
            }
        }catch(Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
huxley
  • 307
  • 3
  • 8
termted
  • 31
  • 1
  • 4

1 Answers1

0

Please set the correct connection string like this

// SQL Connection String with |DataDirectory| substitution string
SqlConnection c = new SqlConnection (
   @"Data Source=.; AttachDbFilename=|DataDirectory|\loonberekening.mdf;Initial Catalog=loonberekening");
Vedank Kulshrestha
  • 220
  • 1
  • 6
  • 23