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.IO;
using System.Data.OleDb;
using System.Data.Common;

namespace subok
public partial class Form1 : Form
public OleDbConnection connect;
static string strconnect = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""C:\Documents and Settings\avupdate\My Documents\db3.mdb";
public OleDbDataAdapter adapter;
public DataSet dtset;
public OleDbCommand cmd;
public Form1()

private void Form1_Load(object sender, EventArgs e)
// TODO: This line of code loads data into the 'db3DataSet.record' table. You can move, or remove it, as needed.

connect = new OleDbConnection(strconnect);
MessageBox.Show("Bukas na ang database!", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information);
Form1 subok =new Form1();


private void button1_Click(object sender, EventArgs e)
dtset = new DataSet("test");
cmd = new OleDbCommand("select*from record");
cmd.CommandType = CommandType.Text;
cmd.Connection = connect;
adapter = new OleDbDataAdapter(cmd);
dtset.Tables[0].TableName = "test";
dataGridView1.DataSource = dtset.Tables["test"];

private void button3_Click(object sender, EventArgs e)
cmd = new OleDbCommand("Insert into record(snum, lastname, fmane, MI, age, bday)" + "values(" + "'" + textBox1.Text + "'" + ", " + "'" + textBox2.Text + "'" + ", " + "'" + textBox3.Text + "'" + ", " + "'" + textBox4.Text + "'" + "," + "'" + Convert.ToInt16(textBox5.Text) + "'" + "," + "'" + Convert.ToDateTime(dateTimePicker1.Value) + "'" + ")", connect);
MessageBox.Show("new record added", "Append", MessageBoxButtons.OK, MessageBoxIcon.Information);


private void button4_Click(object sender, EventArgs e)
cmd = new OleDbCommand("delete from record where snum like" + "'%" + textBox1.Text + "%'", connect);
MessageBox.Show("record deleted", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);


private void button5_Click(object sender, EventArgs e)

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
int row = e.RowIndex;
textBox1.Text = dataGridView1["snum", row].Value.ToString();
textBox2.Text = dataGridView1[1, row].Value.ToString();
textBox3.Text = dataGridView1[2, row].Value.ToString();
textBox4.Text = dataGridView1[3, row].Value.ToString();
textBox5.Text = dataGridView1[4, row].Value.ToString();
dateTimePicker1.Value = DateTime.Parse(dataGridView1[5, row].Value.ToString());

private void fillByToolStripButton_Click(object sender, EventArgs e)
catch (System.Exception ex)



snum [textbox1 here] (snum stands for student number)
fname [textbox2]
lastname [textbox3]
MI [textbox4]
age [textbox5]
bday [DateTimePicker]

(view button)
(add button)
(delete button)
(close button)

l l
l l (this is the DataGridView)
l l
l l
l l
l l

******************this is the Form Format of my program*************

I used MSAccess for the records. The said error was the Argument Exception in this part---> connect = new OleDbConnection(strconnect);

I’m hopeless in this case..

pls help me here…thank you in advance…Ü

i already erased the "" inner mark here.. -->

static string strconnect = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""C:\Documents and Settings\avupdate\My Documents\db3.mdb";

so it turns out to be like this...

static string strconnect = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\avupdate\My Documents\db3.mdb";

but the problem now is this...

the message box saying "bukas na ang database" keeps popping out even if i keep clicking the "ok" button, it still pops out... and the form won't show....='(

9 Years
Discussion Span
Last Post by JerryShaw

Funny... You are launching a new form1 inside your onLoad handler. Each one has this dialog, and each one launches another form1... a logical never ending loop. (until you run out of resources :)

// Jerry

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.