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.Threading.Tasks;
- using System.Data;
- using System.Data.Sql;
- using System.Data.SqlClient;
- namespace sqlTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- string connString = @"Data Source=.\;Initial ...";
- SqlConnection cnn = new SqlConnection(connString);
- cnn.Open();
- SqlCommand cmd = cnn.CreateCommand();
- cmd.CommandText = "sp_Category_Ins";
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@nomeCat","Spazzacamino");
- int nr = cmd.ExecuteNonQuery();
- //if the query returns a table
- SqlCommand cmdR = new SqlCommand("sp_POIforCategory");
- cmdR.CommandType = CommandType.StoredProcedure;
- cmdR.Parameters.AddWithValue("@nomeCat", "Spazzacamino");
- //Version 1
- SqlDataReader drR = cmdR.ExecuteReader();
- DataTable tb1 = new DataTable();
- tb1.Load(drR);
- //Version 2
- SqlDataAdapter daR = new SqlDataAdapter(cmdR);
- daR.Fill(tb1);
- foreach (DataRow dr in tb1.Rows) {/*...................*/ }
- cnn.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment