CSharp examples for System.Data.SqlClient:SqlConnection
Create SqlConnection
using System.Web; using System.Linq; using System.Data.SqlClient; using System.Data; using System.Collections.Generic; using System;/* w w w. j a v a 2 s . co m*/ public class Main{ public static void AddWiadomoscHokej(List<System.Linq.IGrouping<string, string>> hrefList) { try { SqlConnection sqlConnection1 = new SqlConnection("Server=tcp:plps.database.windows.net,1433;Initial Catalog=PLPS;Persist Security Info=False;User ID=tomasoft;Password=Tomason18,;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"); SqlCommand cmd = new SqlCommand(); SqlDataReader reader; cmd.CommandText = "INSERT INTO [dbo].[WiadomosciGKSKatowiceHokej] (Nazwa,DataUtw,Wiadomosc1,Wiadomosc2,Wiadomosc3) VALUES ('" + "" + "','" + DateTime.Now + "','" + hrefList[0].Key + "','" + hrefList[1].Key + "','" + hrefList[2].Key + "')"; cmd.CommandType = CommandType.Text; cmd.Connection = sqlConnection1; sqlConnection1.Open(); cmd.ExecuteNonQuery(); sqlConnection1.Close(); } catch (Exception ex) { AddToLog("Blad dodawania wiadomosci Orlen: " + ex.ToString()); } } }