Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
1
Reply
How to code a button save, so to save to the database?
Sinoyolo Zatelela
13y
4.3k
0
Reply
Submit
firstly you add the namspace....
using System.Data.SqlClient;
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=SR; Initial catalog=nadeem; user id=sa; password=<123>";
con.Open();
SqlCommand cmd = new SqlCommand("insert into login values ('" + textBox1.Text + "',' " + textBox2.Text + " ')", con);
SqlDataReader dr = cmd.ExecuteReader();
MessageBox.Show("save your data");
con.Close();
}
Regards-Nadeem.
nadeem janu
13y
0
Message