I found an article on MS's MSDN forume that helped me a little bit, but I am needing some serious help with editting the code to get it to work. Now I'm getting an error saying that the file type .mdf is not a know file type for the following code:
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"C:\Documents and Settings\jscammel\My Documents\Visual Studio 2005\Projects\Resolution Tracker\Resolution Tracker\Tracker1.mdf;"
Dim objConn As New System.Data.OleDb.OleDbConnection(strConn)
Try
objConn.Open()
'Fill a dataset with records from the Customers table.
Dim strSQL As String
Dim objDataset As New DataSet()
Dim objAdapter As New System.Data.OleDb.OleDbDataAdapter()
strSQL = "Select Contact Number, Lead ID, CSA ID, Customer ID, Order ID, OU, Reason Code, Date, CSNet, BlurbDB, Wizard, Help Pages, Knowledge Center, Website, E-mail, Tech CSNet, Sharepoint, Handouts, Inquiry, EscalationT, Escalation, Reason Why Not, Comments From Table1"
objAdapter.SelectCommand = New System.Data.OleDb.OleDbCommand( _
strSQL, objConn)
objAdapter.Fill(objDataset)
' Create the FileStream to write with.
Dim strFilename As String
strFilename = "C:\Documents and Settings\All Users\Desktop\ContactLog.xml"
Dim fs As New System.IO.FileStream(strFilename, _
System.IO.FileMode.Create)
'Create an XmlTextWriter for the FileStream.
Dim xtw As 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='customers.xsl'")
'Write the XML from the dataset to the file.
objDataset.WriteXml(xtw)
xtw.Close()
MsgBox("Contact data has been exported to C:\Documents and Settings\All Users\Desktop\ContactLog.xml")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Ideally, I'd like to make the location string less static so that I could move the attachment with the program and I'd like to know if there is a way I could edit the code to accept the .mdf file, or is there a way I can translate to a .mdb file?
|