Hi there,
I have a set of questions in one table in my MS-Access database, now i need to create another table counting the number of questions in the first table and create such number of fields in my 2nd table.... can some one help me to do this using vb.net as the front end....please as soon as possible.
thank you

Posted Oct 23, 2009, 11:24 PM EDT
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 31, 2009, 9:50 AM EDT
Here is Solution Working and Tested !!
don't forget to check "Do you like this Answer"
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) 'Get How Many rows are there in The Table 1 Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Database1.accdb;Persist Security Info=True") con.Open() Dim comm As New OleDbCommand("select count(*) from Table1", con) Dim TotalColumns As Integer = Convert.ToInt32(comm.ExecuteScalar()) Try 'If Table2 Already Exist Delete It First if not 'Exist then Error Will Be Suppressed By Try Catch comm = New OleDbCommand("drop table Table2", con) comm.ExecuteNonQuery() Catch End Try ' Create New Blank Table2 without columns comm = New OleDbCommand("create table Table2", con) comm.ExecuteNonQuery() 'Add Columns to Blank Table2 which is Equal to Number of Rows in Table1 For i As Integer = 0 To TotalColumns 'Add Columns to Table comm = New OleDbCommand("alter table Table2 Add Field" & i.ToString() & " Text", con) comm.ExecuteNonQuery() Next 'Finally Close the Connection con.Close() MessageBox.Show("All Operation SuccessFul!!") End SubPosted Oct 31, 2009, 10:47 AM EDT
Feel free to ask ....
With regards
P.Krishna Prasad