Advertisement
touhid_xml

String Formatting Problem in C#

Oct 31st, 2013
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.OleDb;
  10.  
  11. namespace StudentManagement
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Touhid\Documents\db1.mdb");
  16.         public Form1()
  17.         {
  18.             vcon.Open();
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void button1_Click(object sender, EventArgs e)
  23.         {
  24.             String vsql = "INSERT INTO student VALUES(" + textBox1.Text + ", '" + textBox2.Text + "' ," + textBox3.Text + "," + textBox4.Text + "," + textBox5.Text + ", '" + textBox6.Text  +"')";
  25.             String vsql2 = String.Format("INSERT INTO student VALUES((0), '(1)', (2), (3), (4), '(5)')",int.Parse(textBox1.Text),textBox2.Text, int.Parse(textBox3.Text), int.Parse(textBox4.Text), int.Parse(textBox5.Text),textBox6.Text);
  26.          
  27.             MessageBox.Show(vsql2);
  28.             /*OleDbCommand vcom= new OleDbCommand(vsql, vcon);
  29.             vcom.ExecuteNonQuery();
  30.             MessageBox.Show("Data Stored Successfully");
  31.            vcom.Dispose();*/
  32.         }
  33.  
  34.         private void button4_Click(object sender, EventArgs e)
  35.         {
  36.             this.Close();
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement