This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Stored procedure example | |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
using System.Data.Sql; | |
using System.Data.SqlClient; | |
namespace killercodes_in.StoredProcedure | |
{ | |
public partial class Form1 : Form | |
{ | |
public string _connStr_ = "Data Source=127.0.0.1,1433;Initial Catalog=avyukta;User Id=sa;Password=iamadmin;"; | |
SqlCommand cmd; | |
SqlConnection conn; | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
SqlDataAdapter sda; | |
SqlCommand cmd = new SqlCommand(); | |
SqlParameter param; | |
DataSet ds = new DataSet(); | |
int i = 0; | |
conn = new SqlConnection(_connStr_); | |
conn.Open(); | |
cmd.Connection = conn; | |
cmd.CommandType = CommandType.StoredProcedure; | |
cmd.CommandText = "Grade"; | |
sda = new SqlDataAdapter(cmd); | |
sda.Fill(ds); | |
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) | |
{ | |
MessageBox.Show(ds.Tables[0].Rows[i][0].ToString()); | |
} | |
conn.Close(); | |
} | |
} | |
} |