...
c) Connect with C#
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Data; namespace SecureSQL { class Program { static void Main(string[] args) { using (SqlConnection connection = new SqlConnection()) { connection.ConnectionString = "Server=sqlseclab-lsnr1.its.yale.edu;" + "Initial Catalog=master;" + "Integrated Security=true;" + "Encrypt=True;TrustServerCertificate=False"; connection.Open(); using (SqlCommand command = connection.CreateCommand()) { command.CommandText = "select GetDate()"; command.CommandType = CommandType.Text; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Console.WriteLine("{0}", reader[0]); } } } Console.ReadLine(); } } } } |
...