i am facing a problem
actually my name is kazim.i m a final year computer science student.i make a table in access and insert two fields of text type int it.when i insert data in it through c#.then it insert in it correctly, but when i increse the field in the table from 2 to 4.and all are of same data type.then when i insert the data in it,the error is come,that u have not inserted the value for one or more required fields.i will be send u a code.hopefully u will solve my problem.
thanks
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace faproj
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void generalJournal_Click(object sender, EventArgs e)
{
this.Debit.Visible = true;
this.Credit.Visible = true;
this.accpar.Visible = true;
this.comboBox1.Visible = true;
this.comboBox2.Visible = true;
this.textCredit.Visible = true;
this.textDebit.Visible = true;
this.comboBox1.Items.Add("Cash");
this.comboBox1.Items.Add("Supplies");
this.comboBox1.Items.Add("Land");
this.comboBox1.Items.Add("Capital");
this.comboBox1.Items.Add("Account Recievable");
this.comboBox1.Items.Add("Buildings");
this.comboBox1.Items.Add("Note Recievable");
this.comboBox1.Items.Add("Sales Revenue");
this.comboBox1.Items.Add("Tools and Equipments");
this.comboBox1.Items.Add("Account Payable");
this.comboBox1.Items.Add("Note Payable");
this.comboBox1.Items.Add("Utility Expenses");
this.comboBox1.Items.Add("Rent Expense");
this.comboBox1.Items.Add("Salary Expense");
this.comboBox1.Items.Add("Salary Payable");
this.comboBox1.Items.Add("Insurance Expense");
this.comboBox1.Items.Add("Wedges Expense");
this.comboBox2.Items.Add("Cash");
this.comboBox2.Items.Add("Supplies");
this.comboBox2.Items.Add("Land");
this.comboBox2.Items.Add("Capital");
this.comboBox2.Items.Add("Account Recievable");
this.comboBox2.Items.Add("Buildings");
this.comboBox2.Items.Add("Note Recievable");
this.comboBox2.Items.Add("Sales Revenue");
this.comboBox2.Items.Add("Tools and Equipments");
this.comboBox2.Items.Add("Account Payable");
this.comboBox2.Items.Add("Note Payable");
this.comboBox2.Items.Add("Utility Expenses");
this.comboBox2.Items.Add("Rent Expense");
this.comboBox2.Items.Add("Salary Expense");
this.comboBox2.Items.Add("Salary Payable");
this.comboBox2.Items.Add("Insurance Expense");
this.comboBox2.Items.Add("Wedges Expense");
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Connect con = new Connect();
DataSet ds = new DataSet();
con.connectivity();
string az=this.textDebit.Text ;
string bz =this.textCredit.Text ;
string cz = this.comboBox1.SelectedItem.ToString();
string dz = this.comboBox2.SelectedItem.ToString ();
this.textBox1.Text = az;
this.textBox2.Text = bz;
string str = "INSERT INTO Legacy values("+ cz+ "," + dz + "," + az + "," + bz + ")";
OleDbCommand comm = new OleDbCommand(str ,con.conn);
comm.ExecuteNonQuery();
str = "SELECT * FROM Legacy";
OleDbDataAdapter da = new OleDbDataAdapter(str,con.conn);
da.Fill(ds,"Legacy");
this.dataGridView1.DataSource = ds.Tables["Legacy"].DefaultView ;
}
}
}
|