Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

pls help me with this, can't tell the error in this and am new to it

$
0
0
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 csc409
{
    public partial class Form1 : Form
    {
       
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void button1_Click(object sender, EventArgs e)
        {

            string constrng = @"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=c:\users\chigozie\documents\visual studio 2010\Projects\csc409\csc409\register.accdb";
            OleDbConnection coon = new OleDbConnection(constrng);
            coon.Open();
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection=connect;
            cmd.CommandText = "INSERT INTO csc409table([Field1],[Field2],[Field3]) &_VALUES@txt,@txt2,@txt3)";
            cmd.Parameters.Add("@Field1", OleDbType.VarChar).Value = txt;
            cmd.Parameters.Add("@Field2", OleDbType.VarChar).Value = txt2;
            cmd.Parameters.Add("@Field3", OleDbType.VarChar).Value = txt3;
            cmd.ExecuteNonQuery();
            coon.Close();
            //clearing the textboxes
            txt.Text = "";
            txt2.Text = "";
            txt3.Text = "";
        }
    }
}

Viewing all articles
Browse latest Browse all 31927

Trending Articles