Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have managed to get an example:(http://support.microsoft.com/kb/307029/en-us) working that exports from an example mdb file called northwind but In my project I have an sql database and I have tried to change the connectionstring to the mdf database but I recieve this error "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." what do I need to change to get export working from my own database. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Show your code.
Tim "OceanMist" wrote in message ... Hi, I have managed to get an example:(http://support.microsoft.com/kb/307029/en-us) working that exports from an example mdb file called northwind but In my project I have an sql database and I have tried to change the connectionstring to the mdf database but I recieve this error "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done." what do I need to change to get export working from my own database. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is the connection string
private string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ".\\SQLEXPRESS;AttachDbFilename=C:\\Documents and Settings\\Conor\\My Documents\\Visual Studio 2005\\Projects\\CallManSys19Jul\\CMS\\CMSDatabase. mdf;Integrated Security=True;User Instance=True"; and in the button code private void AnalyseButton_Click(object sender, EventArgs e) { OleDbConnection objConn = new OleDbConnection(strConn); try { //Fill a dataset with records from the Customers table. OleDbCommand objCmd = new OleDbCommand( "Select Call_id, name, dept, " + "location, Resolved_by, Problem_Type from Call Reports", objConn); //"Select CustomerID, CompanyName, ContactName, " //+ "Country, Phone from Customers", objConn); OleDbDataAdapter objAdapter = new OleDbDataAdapter(); objAdapter.SelectCommand = objCmd; DataSet objDataset = new DataSet(); objAdapter.Fill(objDataset); //Create the FileStream to write with. System.IO.FileStream fs = new System.IO.FileStream( "C:\\Call Reports.xml", System.IO.FileMode.Create); //Create an XmlTextWriter for the FileStream. System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter( fs, System.Text.Encoding.Unicode); //Add processing instructions to the beginning of the XML file, one //of which indicates a style sheet. // xtw.WriteProcessingInstruction("xml", "version='1.0'"); // xtw.WriteProcessingInstruction("xml-stylesheet", // "type='text/xsl' href='Call Reports.xsl'"); //Write the XML from the dataset to the file. objDataset.WriteXml(xtw); xtw.Close(); //Close the database connection. objConn.Close(); catch (System.Exception ex) { MessageBox.Show(ex.Message); } } I hope this is sufficient code |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Access query results to Excel | Excel Discussion (Misc queries) | |||
Exporting from Excel to CSV results in wrong characters | Excel Discussion (Misc queries) | |||
Mess-up When Exporting to an Excel in Query Analyzer | Excel Programming | |||
Complex Query Not Able To Get Results in Excel | Excel Programming | |||
Error message in Excel after exporting Access query to Excel | Excel Discussion (Misc queries) |