TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
rati sturua
NA
1
665
database conecting c# 2015
Sep 30 2015 4:56 AM
i am Beginner programmer i wont to Connect database to windows form (textbox1,textbox2)
.my kod.not works
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'database1DataSet.Students' table. You can move, or remove it, as needed.
this.studentsTableAdapter.Fill(this.database1DataSet.Students);
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection();//?????????????????????????????????????????
try
{
string sql = "INSSERT INTO Students(Student_Id,Studentname) values(" + textBox1.Text+",'"+textBox2.Text+")";
SqlCommand exeSql = new SqlCommand(sql, cn);
cn.Open();
exeSql.ExecuteNonQuery();
}
catch(Exception ex)
{
}
finally
{
}
}
}
}
Reply
Answers (
2
)
C# Sharing and Secuirty
how to cnvert string to int for date???