web.config
<connectionStrings>
<add name="conString" connectionString="Data Source=.\SQLEXPRESS; database=Northwind;Integrated Security=true"/>:
</connectionStrings>
Used Stored procedure
CREATE PROCEDURE [dbo].[AddUser]
(
@FName varchar(50),
@LName varchar(50),
@DateOfBirth datetime,
@City varchar(50),
@State varchar(50)
)
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO UserDetails (FName, LName, DateOfBirth, City, State)
VALUES (@FName, @LName, @DateOfBirth, @City, @State)
END
C# code
String ConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(ConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "AddUser";
cmd.Parameters.Add("@FName",SqlDbType.VarChar).Value = txtFName.Text.Trim();
cmd.Parameters.Add("@LName", SqlDbType.VarChar).Value = txtLName.Text.Trim();
cmd.Parameters.Add("@DateOfBirth", SqlDbType.DateTime).Value = txtDOB.Text.Trim();
cmd.Parameters.Add("@City", SqlDbType.VarChar).Value = txtCity.Text.Trim();
cmd.Parameters.Add("@State", SqlDbType.VarChar).Value = txtState.Text.Trim();
cmd.Connection = con;
try
{
con.Open();
cmd.ExecuteNonQuery();
lblMessage.Text = "Record inserted successfully";
}
catch (Exception ex)
{
throw ex;
}
finally
{
con.Close();
con.Dispose();
}
The code just work fine: Nice code.
ReplyDeletenice code yess
ReplyDeletepoor.....................code,,,,,,worst i ever seen............
ReplyDeletenice work.........
ReplyDeleteGood coding,
ReplyDeleteone who is saying worse, doesn't know OOPs concept
thanks dude. might help me.
ReplyDeletegood code,
ReplyDeleteit's really healpfull ,
Give me complete coding All DML operations
its really nice one
ReplyDeletecan you post the code for searching the records....
ReplyDeleteit is very helpd me
ReplyDeletearticle flows really awesome....thanks for helping biginers ali.rameez72@yahoo.com
ReplyDeletevery good code.....keep it up help to helpful people..... thank u so much......god bless u.....
ReplyDeletenice work
ReplyDeletethe sp seems to have these errors
ReplyDelete-----------------------------------
Msg 102, Level 15, State 1, Procedure write_categs, Line 2
Incorrect syntax near '{'.
Msg 137, Level 15, State 2, Procedure write_categs, Line 10
Must declare the scalar variable "@cat1".
Gud one..thanks.
ReplyDeletethanks....this code helps me
ReplyDeleteThanks .. Its working & helps for my exam preparation ..
ReplyDeleteit is working fine....thanku
ReplyDeletenice post..you can visit following link to get code of storing data in database using asp.net c#.
ReplyDeleteClick Here
nice post..you can visit following link to get code of how to store data in database using stored procedure and 3-tier architecture.100% verified code.
ReplyDeleteClick Here
suppose in stored procedure contain some int values like salary empid then got error plese pass values like that how?
ReplyDeleteIts working
ReplyDeleteGud Code
ReplyDeletethanks .....
ReplyDeletethanks its cool
ReplyDeletenice.....
ReplyDeletebitlis
ReplyDeletekastamonu
çorum
van
sakarya
X2Hİ
A4466
ReplyDeleteNevşehir Parça Eşya Taşıma
Çerkezköy Marangoz
Kocaeli Lojistik
Bitlis Lojistik
Ankara Evden Eve Nakliyat
Şırnak Parça Eşya Taşıma
Ankara Parke Ustası
Balıkesir Evden Eve Nakliyat
Bingöl Parça Eşya Taşıma
C3112
ReplyDeleteÇerkezköy Boya Ustası
Tekirdağ Boya Ustası
Balıkesir Evden Eve Nakliyat
Niğde Şehirler Arası Nakliyat
Antalya Parça Eşya Taşıma
Konya Evden Eve Nakliyat
Kütahya Lojistik
Konya Parça Eşya Taşıma
Edirne Şehirler Arası Nakliyat
DB002
ReplyDeleteArtvin Parça Eşya Taşıma
Hakkari Lojistik
Malatya Evden Eve Nakliyat
Osmaniye Şehirler Arası Nakliyat
Aksaray Evden Eve Nakliyat
Mersin Parça Eşya Taşıma
Isparta Lojistik
Niğde Evden Eve Nakliyat
Antalya Şehirler Arası Nakliyat
D3B61
ReplyDelete%20 binance komisyon indirimi
A6939
ReplyDeletereferans kodu %20
734CF
ReplyDeleteCoin Kazanma Siteleri
Parasız Görüntülü Sohbet
Coin Kazma
Parasız Görüntülü Sohbet
Kripto Para Madenciliği Nedir
Discord Sunucu Üyesi Satın Al
Twitter Trend Topic Hilesi
Okex Borsası Güvenilir mi
Tiktok Takipçi Satın Al
شركة عزل اسطح بالجبيل 1yDevf3xjv
ReplyDelete