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.SqlClient;
namespace SangeetDemo
{
public partial class Form1 : Form
{
SqlConnection con;
SqlCommand command;
string sqlcon = @"Server=Sangeeth-PC\DEV01;Database=AdventureWorks2012;User ID=sa; Password=1234";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
con = new SqlConnection();
con.ConnectionString = sqlcon;
try
{
con.Open();
command = new SqlCommand();
command.Connection = con;
command.CommandText = "Proc_Test";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@name", "abc");
command.Parameters.AddWithValue("@trns_dt", DateTime.UtcNow);
SqlDataReader reader = command.ExecuteReader();
if (reader != null)
{
while (reader.Read())
{
MessageBox.Show(reader["SalesOrderID"].ToString());
}
}
}
catch (Exception ex)
{
}
}
}
}
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.SqlClient;
namespace SangeetDemo
{
public partial class Form1 : Form
{
SqlConnection con;
SqlCommand command;
string sqlcon = @"Server=Sangeeth-PC\DEV01;Database=AdventureWorks2012;User ID=sa; Password=1234";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
con = new SqlConnection();
con.ConnectionString = sqlcon;
try
{
con.Open();
command = new SqlCommand();
command.Connection = con;
command.CommandText = "Proc_Test";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@name", "abc");
command.Parameters.AddWithValue("@trns_dt", DateTime.UtcNow);
SqlDataReader reader = command.ExecuteReader();
if (reader != null)
{
while (reader.Read())
{
MessageBox.Show(reader["SalesOrderID"].ToString());
}
}
}
catch (Exception ex)
{
}
}
}
}
No comments:
Post a Comment