Advertisement
Guest User

Untitled

a guest
Apr 20th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Data.SqlClient;
  7.  
  8. namespace Sql_Access {
  9. class Program {
  10. static void Main(string[] args) {
  11. SqlConnection connection = toConnect();
  12. connection.Open();
  13. Console.WriteLine("Worked");
  14. }
  15.  
  16. public static SqlConnection toConnect() {
  17. Console.WriteLine("Enter Username");
  18. string username = "user id=" + Console.ReadLine();
  19. Console.WriteLine("Enter Password");
  20. string password = "password=" + Console.ReadLine();
  21. Console.WriteLine("Enter Url");
  22. string url = "server=" + Console.ReadLine(); ;
  23. SqlConnection connection = new SqlConnection(username + ";" + password + ";" + url + ";" + "Trusted_Connection=yes;" + "database=database; " + "connection timeout=30");
  24. return connection;
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement