Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data.SqlClient;
- namespace _4004Iteration1{
- class Program{
- static void Main(string[] args){
- SqlConnection connection = new SqlConnection("user id=L;" +
- "server=localhost;" +
- "Trusted_Connection=yes;" +
- "database=HospitalDB; " +
- "connection timeout=30");
- try{
- connection.Open();
- }
- catch (Exception e){
- Console.WriteLine(e.ToString());
- }
- SqlCommand insert = new SqlCommand("INSERT INTO test (numbers) values (105)", connection);
- insert.ExecuteNonQuery();
- try{
- SqlDataReader myReader = null;
- SqlCommand select = new SqlCommand("select * from test", connection);
- myReader = select.ExecuteReader();
- while (myReader.Read()){
- Console.WriteLine(myReader["numbers"].ToString());
- }
- }
- catch (Exception e){
- Console.WriteLine(e.ToString());
- }
- System.Console.ReadLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment