Hi all
I just want to know, how to insert the data from a datagrid into access database?
please help me....
:'(
Hi all
I just want to know, how to insert the data from a datagrid into access database?
please help me....
:'(
im not geting clearly. do u want to transfer database data to datagrid or what ur expect...
Hi all
I just want to know, how to insert the data from a datagrid into access database?
please help me....
:'(
I fill the datagrid with a data and I don't know how to insert that data into a access database. I want to transfer the data from datagrid to the access database
Dear all,
this is my code for transfer data from datagrid view to access database.
but why i can't transfer data more than one row?
can somebody help me?
please...:'(
------------------------------------------------------------------------------------------------
connection class is contains:
static string strCon = "provider=Microsoft.Jet.OLEDB.4.0;data source=D:\\c.mdb";
public static OleDbConnection oleCon = new OleDbConnection(strCon);
public static OleDbCommand oleCommand = oleCon.CreateCommand();
------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace test
{
public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
connection.oleCon.Open();
string[,] a= new string[100,100];
int countRow = dataGridView1.RowCount;
int countCol = dataGridView1.ColumnCount;
Console.WriteLine("row = " + countRow);
Console.WriteLine("col = " + countCol);
int j = 0;
int k = 0;
string data = "'";
for (k = 0; k < (countRow-1); k++)
{
for (j = 0; j < (countCol); j++)
{
Console.WriteLine("j=" + j);
Console.WriteLine("k=" + k);
a[j,k] = string.Format("" + dataGridView1[j, k].Value);
if( (j == (countCol - 1))&&(k == l))
{
data = data + a[j, k] + "'";
}else
if (j < (countRow - 1))
{
data = data + a[j, k] + "','";
}
Console.WriteLine("a[" + j + "," + k + "]=" + a[j, k]);
Console.WriteLine("a = " + data);
}
connection.oleCommand.CommandText =
"INSERT INTO customer(name,address) " +
"VALUES (" + data + ")";
connection.oleCommand.ExecuteNonQuery();
}
}
}
}
Just forget it this problem is solved,thanks all
hey ,
in line 43:
if( (j == (countCol - 1))&&(k == l))
what is l
it is not defined??
and also i need to know what is this code for?? i am trying to figure it out but it is a little bit difficult.
thankx
hi
please check this link related to grid view
http://www.mindstick.com/Articles/60574323-7e6c-424e-9265-93f7d534a64c/
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.