hi
in sql server 2008
create database solution
go
create table test
(
filed1 int identity primary key,
filed2 nvarchar(50),
filed3 nvarchar(50),
filed4 bigint)
)
go
create proc ups_test
@a nvarchar(50),
@b nvarchar(50),
@c bigint
as
begin
insert dbo.test
values(@a,@b,@c)
end
in the above code first create database solution then create table test and at the end of all create proc ups_test
then go and create c# code
in the click event write this and fill the procedure value with 3 text box value
private void btninsert_Click(object sender, EventArgs e)
{
try
{
SqlCommand sqm = new SqlCommand("ups_insert", new SqlConnection("data source=.;database=test;uid=your sql username;pwd=your sql password));
sqm.Connection.Open();
sqm.CommandType = CommandType.StoredProcedure;
sqm.Parameters.Add("@a", SqlDbType.NVarChar, 5).Value = txtyear.Text;
sqm.Parameters.Add("@b", SqlDbType.NVarChar, 5).Value = txtmonth.Text;
sqm.Parameters.Add(@c, SqlDbType.BigInt).Value = txtqty.Text;
sqm.ExecuteNonQuery();
sqm.Connection.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}