please does someone knows the source of how to connect mysql server with c sharp 2010
because i m actually trying to connect my program with c sharp but it shows
me an error here is the code :
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 WindowsFormsApplication7 { public partial class Form1 : Form { DataSet ds = new DataSet(); SqlConnection cs = new SqlConnection(" Data Source=GILO-PC\\NEWINSTANCE; Initial Catalog=school;Integrated Security=TRUE"); SqlDataAdapter da = new SqlDataAdapter(); BindingSource tblContactsBS = new BindingSource(); public Form1() { InitializeComponent(); } private void textBox2_TextChanged(object sender, EventArgs e) { } private void btnAddRecord_Click(object sender, EventArgs e) { da.InsertCommand = new SqlCommand("Insert Into tblContacts Values(@Firstname,@Lastname)", cs); da.InsertCommand.Parameters.Add("@Firstname", SqlDbType.VarChar).Value = txtFirstname.Text; da.InsertCommand.Parameters.Add("@Lastname", SqlDbType.VarChar).Value = txtLastname.Text; cs.Open(); da.InsertCommand.ExecuteNonQuery() ; cs.Close() } } }
This post has been edited by macosxnerd101: 13 December 2010 - 10:17 AM
Reason for edit:: Added code tags and moved to C#.