Click here to Skip to main content
16,021,112 members

Comments by Dhanashri13 (Top 1 by date)

Dhanashri13 5-Dec-12 5:50am View    
thanks for help..
but in this code

Collapse | Copy Code
private void Form1_Load(object sender, System.EventArgs e)
{
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"..\..\DataTableSample.xls");
Worksheet sheet = workbook.Worksheets[0];
DataTable data= sheet.ExportDataTable();
//set the string connection to be the local databasestring
string connectionStr="";
SqlConnection conn= new SqlConnection(connectionStr);
for (int i=0;i<data.rows.count;i++)>
{
DataRow row=data.Rows[i];
int columnCount=data.Columns.Count;
string[] columns=new string[columnCount];
for(int j=0;j<columncount;j++)> {
columns[j]=row[j].ToString();
}
// suppose there are only three columns in your datatable
SqlCommand command=new SqlCommand ("insert into DataTableSample(column1,column2,column3) values('"+columns[0]+"','"+columns[1]+
" ','"+columns[2]+"')");
command.ExecuteNonQuery();
}
conn.Close();
}

error occur=
Server Error in '/ecom' Application.
Format of the initialization string does not conform to specification starting at index 0.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.

Source Error:


Line 52: //set the string connection to be the local databasestring
Line 53: string connectionStr = "ConnectionString";
Line 54: SqlConnection conn= new SqlConnection(connectionStr);
Line 55: for (int i=0;i