Hi. I wrote a program that connects to an excel database but it makes an error in connection string line. Here's the code:
Java
OleDbConnectionConnection=newOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\DataBase2.xls;" +
"Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";");
OleDbDataAdapterAdapter=newOleDbDataAdapter("Select * from Sheet1", Connection);
DataSetDS=newDataSet();
DataTableDT=newDataTable();
Adapter.Fill(DS);
DT = DS.Tables[0];
TextBox[,] TB = newTextBox[DT.Rows.Count, DT.Columns.Count];
for (inti=0; i < DT.Rows.Count; i++)
{
for (intj=0; j < DT.Columns.Count; j++)
{
TB[i, j] = newTextBox();
TB[i, j].Parent = this;
TB[i, j].Size = newSize(30, TB[i, j].Size.Height);
TB[i, j].Location = newPoint(20 + j * TB[i, j].Size.Width, 20 + i * TB[i, j].Size.Height);
TB[i, j].Show();
}
}
introw=0, col = 0;
foreach (DataRow DR in DT.Rows)
{
for (col = 0; col < DT.Rows.Count; col++)
TB[row, col].Text = DR[col].ToString();
row++;
}
It makes a runtime error on lines 1 and 2 and says: "Format of the Initialization string does not conform to specification starting at index 93." What's the problem?
BTW, I use office 2007, does it makes problem? Thanks :-)
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Raghvendr Singh81 reputationPosted Jan 22, 2011, 12:54 AM EST
0
Hello
Try this one
OleDbConnection Connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\DataBase2.xls;" + "Extended Properties=Excel 8.0;HDR=Yes;IMEX=1;");
0
Majid KamaliRank #6,453 · 266 reputationPosted Jan 23, 2011, 5:09 AM EST
0
I tried it but it says "Could not find installable ISAM". What's the problem.
Raghvendr Singh81 reputationPosted Jan 22, 2011, 12:54 AM EST
Try this one
OleDbConnection Connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\DataBase2.xls;" +
"Extended Properties=Excel 8.0;HDR=Yes;IMEX=1;");
Majid KamaliRank #6,453 · 266 reputationPosted Jan 23, 2011, 5:09 AM EST
What's the problem.