Life is a Race Thanks & Regards By Sabari Mahesh P M
This is the code using System.Data.SqlClient; using System.IO; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Smo; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string sqlConnectionString = "Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True"; FileInfo file = new FileInfo("C:\\myscript.sql"); string script = file.OpenText().ReadToEnd(); SqlConnection conn = new SqlConnection(sqlConnectionString); Server server = new Server(new ServerConnection(conn)); server.ConnectionContext.ExecuteNonQuery(script); } } }
SqlCommand cmd = new SqlCommand("SProcedureName", cn); SqlDataAdapter adp = new SqlDataAdapter(cmd); DataSet dset = new DataSet(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = id.ToString(); cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = NameString; cn.Open(); cmd.ExecuteNonQuery(); adp.Fill(dset); YourGridID.DataSource = dset; YourGridID.DataBind();
Login to post response