Windows Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • soulami
    New Member
    • Apr 2012
    • 1

    Windows Form

    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.OleDb;
    namespace Form2
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void patientBindingNavigatorSaveItem_Click(object sender, EventArgs e)
            {
                this.Validate();
                this.patientBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.patientDataSet);
    
            }
    
            private void patientBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
            {
                this.Validate();
                this.patientBindingSource.EndEdit();
                this.tableAdapterManager.UpdateAll(this.patientDataSet);
    
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                // TODO: This line of code loads data into the 'patientDataSet.patient' table. You can move, or remove it, as needed.
                this.patientTableAdapter.Fill(this.patientDataSet.patient);
    
            }
    
           
    
            private void submit_Click(object sender, EventArgs e)
            {
    string s="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\rhema\\Documents\\Visual Studio 2008\\Projects\\Form2\\Form2\\patient1.mdb;
        OleDbConnection conn=new OleDbConnection(s);
                conn.Open();
                int patient_id=int.Parse(TextBox1.text);
                string name=TextBox2.text;
                string guardians=TextBox3.text;
                int weight=int.Parse(TextBox4.text);
               int heigtht=int.Parse(TextBox5.text);
               string sex=TextBox6.text;
                string address=TextBox7.text;
                int phoneno=int.Parse(TextBox8.text);
                OleDbCommand cmd=new OleDbCommand("insert into patient values("+patient_id+",'" +name+",'" +guardians+",'" +weight+",'" +Height+",'" +sex+",'" +address+",'" +phoneno+"')",conn); 
                conn.Close();
    
    
            }
        }
    }
    im getting 2 errors as NewLine constant and ; missing in the line string s="Provider=Mic rosoft.Jet.OLED B.4.0;Data Source=C:\\User s\\rhema\\Docum ents\\Visual Studio 2008\\Projects\ \Form2\\Form2\\ patient1.mdb;
    pls help me
    Last edited by PsychoCoder; Apr 17 '12, 05:10 PM. Reason: Added code tags
  • rekedtechie
    New Member
    • Feb 2012
    • 51

    #2
    Code:
    //i think you forgot to put a double quote at line 46..
    
    String s = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\folder\\sub folder\\sub folder\\sub folder\\yourDB.mdb";
    
    //and maybe you can use the @ to scape all characters you want to scape?.
    
    //like this..
    String s = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\folder\sub folder\sub folder\sub folder\yourDB.mdb";

    Comment

    Working...