01.
public
Form2()
02.
{
03.
InitializeComponent();
04.
05.
server =
"localhost"
;
06.
database =
"db2"
;
07.
uid =
"root"
;
08.
password =
"root"
;
09.
string
connectionString;
10.
connectionString =
"Server=localhost;User Id=root; Password=1234; Database=db2; Pooling=false"
;
11.
12.
connection =
new
MySqlConnection(connectionString);
13.
connection.Open();
14.
}
15.
private
void
button1_Click(
object
sender, EventArgs e)
16.
{
17.
18.
MySql.Data.MySqlClient.MySqlCommand objCmd;
19.
String date = dateTimePicker1.Text;
20.
String re_date = dateTimePicker2.Text;
21.
String re_p =
null
;
22.
String pay=
null
;
23.
24.
if
(radioButton1.Checked)
25.
re_p =
"this place"
;
26.
else
if
(radioButton2.Checked)
27.
re_p =
"Fax"
;
28.
else
29.
re_p =
"post"
;
30.
31.
if
(comboBox1.SelectedIndex == 0)
32.
pay =
"money"
;
33.
else
if
(comboBox1.SelectedIndex == 1)
34.
pay =
"receipt"
;
35.
else
if
(comboBox1.SelectedIndex == 2)
36.
pay =
"transfer"
;
37.
else
if
(comboBox1.SelectedIndex == 3)
38.
pay =
"unpaid"
;
39.
40.
41.
String strSQL =
"insert into profile values('"
+ ID.Text.Trim() +
"','"
+ date +
"','"
+ name.Text.Trim() +
"','"
+ adr.Text.Trim() +
"','"
+ tel.Text.Trim() +
"','"
+ fax.Text.Trim() +
"','"
+ mail.Text.Trim() +
"','"
+ obj.Text.Trim() +
"','"
+ num.Text.Trim() +
"','"
+ syn.Text.Trim() +
"','"
+ namet.Text.Trim() +
"')"
;
42.
43.
44.
objCmd =
new
MySql.Data.MySqlClient.MySqlCommand();
45.
objCmd.Connection = connection;
46.
objCmd.CommandText = strSQL;
47.
objCmd.ExecuteNonQuery();
48.
MessageBox.Show(
"complete"
);
49.
connection.Close();
50.
}