Afzaal Khan
asked on
Need to pass connection string through config
Hi Experts,
Need your help.
I am importing excel sheet to Sqldatabase by Sqlbulkcopy.
-------------------------- ---------- ---------- ---------- ------
using (SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection) )
{
// Destination table name. Table name is sheet name minus any $
sqlBulk.DestinationTableNa me = sheetName.Replace("$", "");
foreach (var column in dt.Columns)
{
sqlBulk.ColumnMappings.Add (column.To String(), column.ToString());
}
sqlBulk.WriteToServer(dt);
}
Oledbconn.Close();
}
-------------------------- ---------- ---------- ---------- ---------
I have to get connection string from config instead of hardcoded strConnection Can you help me how I can pass here
Need your help.
I am importing excel sheet to Sqldatabase by Sqlbulkcopy.
--------------------------
using (SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection)
{
// Destination table name. Table name is sheet name minus any $
sqlBulk.DestinationTableNa
foreach (var column in dt.Columns)
{
sqlBulk.ColumnMappings.Add
}
sqlBulk.WriteToServer(dt);
}
Oledbconn.Close();
}
--------------------------
I have to get connection string from config instead of hardcoded strConnection Can you help me how I can pass here
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Connection Strings and Configuration Files