Format of the initialization string does not conform to specification starting at index 0.?????

Sep 4 2008 8:17 AM

I'm trying to export data from my database to an excel spreadsheet using bulkcopy.when i run my code it throws "Format of the initialization string does not conform to specification starting at index 0." when it gets to the source connectionString.What am i missing or what am i doing wrong plz help.here is my code

public class CopyData

{

string _sourceConnectionString = "Data Source= sict-sql;Initial Catalog=PSAtechZ;Integrated Security=True";

string _destinationConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "E:\\+PSATECHZ EYES ONLY+\\PSAtechZTimetableSystem\\Students.xls" + "; Extended Properties='Excel 12.0; IMEX=1; HDR=YES'";

public CopyData(string sourceConnectionString, string destinationConnectionString)

{

_sourceConnectionString = sourceConnectionString;

_destinationConnectionString = destinationConnectionString;

}

public void CopyTable(string StudentModule)

{

using (SqlConnection source = new SqlConnection(_sourceConnectionString))

{

string sql = string.Format("SELECT * FROM [{0}]", StudentModule);

SqlCommand command = new SqlCommand(sql, source);

source.Open();

SqlDataReader dr = command.ExecuteReader();

//IDataReader dr = command.ExecuteReader();

using (SqlBulkCopy copy = new SqlBulkCopy(_destinationConnectionString))

{

copy.DestinationTableName = StudentModule;

copy.WriteToServer(dr);

}

}

}

}

i call this class  under button export.


Answers (1)