By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,619 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Windows Form

P: 1
Expand|Select|Wrap|Line Numbers
  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. namespace Form2
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         private void patientBindingNavigatorSaveItem_Click(object sender, EventArgs e)
  20.         {
  21.             this.Validate();
  22.             this.patientBindingSource.EndEdit();
  23.             this.tableAdapterManager.UpdateAll(this.patientDataSet);
  24.  
  25.         }
  26.  
  27.         private void patientBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
  28.         {
  29.             this.Validate();
  30.             this.patientBindingSource.EndEdit();
  31.             this.tableAdapterManager.UpdateAll(this.patientDataSet);
  32.  
  33.         }
  34.  
  35.         private void Form1_Load(object sender, EventArgs e)
  36.         {
  37.             // TODO: This line of code loads data into the 'patientDataSet.patient' table. You can move, or remove it, as needed.
  38.             this.patientTableAdapter.Fill(this.patientDataSet.patient);
  39.  
  40.         }
  41.  
  42.  
  43.  
  44.         private void submit_Click(object sender, EventArgs e)
  45.         {
  46. string s="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\rhema\\Documents\\Visual Studio 2008\\Projects\\Form2\\Form2\\patient1.mdb;
  47.     OleDbConnection conn=new OleDbConnection(s);
  48.             conn.Open();
  49.             int patient_id=int.Parse(TextBox1.text);
  50.             string name=TextBox2.text;
  51.             string guardians=TextBox3.text;
  52.             int weight=int.Parse(TextBox4.text);
  53.            int heigtht=int.Parse(TextBox5.text);
  54.            string sex=TextBox6.text;
  55.             string address=TextBox7.text;
  56.             int phoneno=int.Parse(TextBox8.text);
  57.             OleDbCommand cmd=new OleDbCommand("insert into patient values("+patient_id+",'" +name+",'" +guardians+",'" +weight+",'" +Height+",'" +sex+",'" +address+",'" +phoneno+"')",conn); 
  58.             conn.Close();
  59.  
  60.  
  61.         }
  62.     }
  63. }
im getting 2 errors as NewLine constant and ; missing in the line string s="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\rhema\\Documents\\Visual Studio 2008\\Projects\\Form2\\Form2\\patient1.mdb;
pls help me
Apr 17 '12 #1
Share this Question
Share on Google+
1 Reply


P: 51
Expand|Select|Wrap|Line Numbers
  1. //i think you forgot to put a double quote at line 46..
  2.  
  3. String s = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\folder\\sub folder\\sub folder\\sub folder\\yourDB.mdb";
  4.  
  5. //and maybe you can use the @ to scape all characters you want to scape?.
  6.  
  7. //like this..
  8. String s = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\folder\sub folder\sub folder\sub folder\yourDB.mdb";
  9.  
Apr 18 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.