In c# .net
Can some guide importing whats in my datagridview right into MS Access 2007.
I want to be able to point to the .mdb file that I want or just simply import to MS Access 2007
can some one guide me,
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
David SmithPosted Feb 26, 2010, 2:29 PM
alot of people dont know. So be careful guys . I change Index to CIfIndex and it work perfectly find.
But I after the program finish update its get a error saying object reference is not set to an instance of an object. I think thats a null issue, how can i advoid that.
David SmithPosted Feb 25, 2010, 8:51 PM
David SmithPosted Feb 25, 2010, 10:52 AM
kiran kumarPosted Feb 25, 2010, 10:14 AM
David SmithPosted Feb 25, 2010, 10:02 AM
kiran kumarPosted Feb 25, 2010, 3:50 AM
David SmithPosted Feb 25, 2010, 3:19 AM
David SmithPosted Feb 25, 2010, 3:19 AM
kiran kumarPosted Feb 25, 2010, 3:16 AM
mark the answer if it helps you
David SmithPosted Feb 25, 2010, 3:15 AM
also do I use integer for the OleDbTpyr for the int column, I tried all of this, let me make sure, did you get my project
kiran kumarPosted Feb 25, 2010, 3:13 AM
MARK THE ANSWER IF IT HELPS YOU
kiran kumarPosted Feb 25, 2010, 3:10 AM
why you go for varchar,take the datatype as datetime
mark the answer if it helps you
David SmithPosted Feb 25, 2010, 2:53 AM
the properties are
int Index
datetime Op_Time_Stamp
text UUT_MSN
text OperationID
text Etag
text EDescription
text E_Time_Stamp1
text E_Time_Stamp2
text EValue
I think it fails at the datetime property im not for sure, I have 916 rows in the datatable right now, so I didnt step through all of the rows
but
kiran kumarPosted Feb 25, 2010, 2:25 AM
kiran kumarPosted Feb 25, 2010, 2:22 AM
David SmithPosted Feb 25, 2010, 1:50 AM
Also karan if my column headers in access are int , datetime, text, text , text, text, text, text does thats matter in code.
meaning the OleDbType.VarChar, 50.
should it be this way
OleDbType.Interger, 50
OleDbType.DBDatetime, 50
OleDbType.VarChar, 50
OleDbType.VarChar, 50
OleDbType.VarChar, 50
OleDbType.VarChar, 50
OleDbType.VarChar, 50
OleDbType.VarChar, 50
David SmithPosted Feb 25, 2010, 12:57 AM
David SmithPosted Feb 25, 2010, 12:09 AM
David SmithPosted Feb 24, 2010, 11:33 PM
what do you mean try adding rows dynamically?
kiran kumarPosted Feb 24, 2010, 11:22 PM
hope it resolves your problem
mark the answer if it helps you
kiran kumarPosted Feb 24, 2010, 8:31 PM
David SmithPosted Feb 24, 2010, 4:59 PM
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\z1083774\\Desktop\\CIF CCA UTILITY\\Working Project CIF\\Software Info\\CifCLUOpDataLibrary\\WindowsFormsApplication1\\bin\\Debug\\CLU_OpData.mdb";
objConnection = new OleDbConnection(strConnection);
objConnection.ConnectionString = strConnection;
objConnection.Open();
OleDbCommand cmd = new OleDbCommand("insert into
CLU_OpData(Index,Op_Time_Stamp,UUT_MSN,OperationID,Etag,EDescription,E_Time_Stamp1,E_Time_Stamp2,EValue)values(@Index,@Op_Time_Stamp,@UUT_MSN,@OperationID,@Etag,@EDescription,@E_Time_Stamp1,@E_Time_Stamp2,@EValue)", objConnection);
for (int i = 0; i < dataGridView2.RowCount; i++)
{
OleDbParameter odbpIndex = new OleDbParameter("@Index", OleDbType.VarChar, 50);
odbpIndex.Value = this.dataGridView2.Rows[i].Cells[0].Value.ToString();
cmd.Parameters.Add(odbpIndex);
OleDbParameter odbpOpTimeStamp = new OleDbParameter("@Op_Time_Stamp", OleDbType.VarChar, 50);
odbpOpTimeStamp.Value = dataGridView2.Rows[i].Cells[1].Value.ToString();
cmd.Parameters.Add(odbpOpTimeStamp);
OleDbParameter odbpUutMsn = new OleDbParameter("@UUT_MSN", OleDbType.VarChar, 50);
odbpUutMsn.Value = dataGridView2.Rows[i].Cells[2].Value.ToString();
cmd.Parameters.Add(odbpUutMsn);
OleDbParameter odbpOperationID = new OleDbParameter("@OperationID", OleDbType.VarChar, 50);
odbpOperationID.Value = this.dataGridView2.Rows[i].Cells[3].Value.ToString();
cmd.Parameters.Add(odbpOperationID);
OleDbParameter odbpEtag = new OleDbParameter("@Etag", OleDbType.VarChar, 50);
odbpEtag.Value = dataGridView2.Rows[i].Cells[4].Value.ToString();
cmd.Parameters.Add(odbpEtag);
OleDbParameter odbpEDescription = new OleDbParameter("@EDescription", OleDbType.VarChar, 50);
odbpEDescription.Value = this.dataGridView2.Rows[i].Cells[5].Value.ToString();
cmd.Parameters.Add(odbpEDescription);
OleDbParameter odbpEtimeStamp1 = new OleDbParameter("@E_Time_Stamp1", OleDbType.VarChar, 50);
odbpEtimeStamp1.Value = dataGridView2.Rows[i].Cells[6].Value.ToString();
cmd.Parameters.Add(odbpEtimeStamp1);
OleDbParameter odbpEtimeStamp2 = new OleDbParameter("@E_Time_Stamp2", OleDbType.VarChar, 50);
odbpEtimeStamp2.Value = this.dataGridView2.Rows[i].Cells[7].Value.ToString();
cmd.Parameters.Add(odbpEtimeStamp2);
OleDbParameter odbpEvalue = new OleDbParameter("@EValue", OleDbType.VarChar, 50);
odbpEvalue.Value = this.dataGridView2.Rows[i].Cells[8].Value.ToString();
cmd.Parameters.Add(odbpEvalue);
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
kiran kumarPosted Feb 23, 2010, 10:30 PM
here is the screen shots of my sample project.
you can add rows dynamically.enter the no of rows in the textbox to be added in the datagrid and click on the button "add rows",after doing this enter the values in datagrid and click on the button "save to access database" and a window appears informing you that your values were saved to access database
PLEASE MARK THE ANSWER IF IT HELPS YOU
Sam HobbsPosted Feb 23, 2010, 10:18 PM
See Visual C++ Guided Tour for a worthwhile tour, except you don't need to do them in the order they appear.