Szenario:
User selects a XML File ("products.xml") to import newest Data.
Data should replace Data in an existing Acess File which is connected
via Dataadapter (daadaptFLR). Bevore the Existing Data are deleted with
RunSQL("DELETE * From Tbl_Fl_Rundleitung").
Function the Works:
If I copy the File from the directory of the Application.exe then it
works fine.
Funktion Bugy:
If I select the same file from another directory, the
UpdateTable(dalForm.daadaptFLR, dsNew.Tbl_Fl_Rundleitung) Function
fails. With following Error: Please remove Index or Constrains to
prevent doubled Values. My Dataset seems to be loaded when i give it to
a datagrid. And i can see a red attention hint with the same Error in
first Line of Datagrid.
I'll be thankfull for any kind of Help.
Greetz from Munich
Private Sub btOFD_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btOFD.Click
Dim ofd As New OpenFileDialog
ofd.ShowDialog()
Try
File.Copy(ofd.FileName, Application.StartupPath() +
"\products.xml", True)
pnStatus.BackColor = System.Drawing.Color.Green
Catch ex As Exception
pnStatus.BackColor = System.Drawing.Color.Red
End Try
End Sub
Private Sub checkGeneratedXML()
Dim dsNew As New dsPreise
Dim dsHolder As New dsPreise
Dim fstream As FileStream
Dim dalForm As New frmPreise
RunSQL("DELETE * From Tbl_Fl_Rundleitung")
RunSQL("DELETE * From Tbl_Flexibel")
RunSQL("DELETE * From Tbl_Front_St_Mdl")
RunSQL("DELETE * From Tbl_Klm_Block")
RunSQL("DELETE * From Tbl_Zubehoer")
'DAten aus XML einlesen
dsNew.Clear()
dsNew.ReadXml(Application.StartupPath() + "\products.xml")
'XmlReadMode.DiffGram , XmlReadMode.ReadSchema
dgLoadTEst.DataSource = dsNew
UpdateTable(dalForm.daadaptFLR, dsNew.Tbl_Fl_Rundleitung)
UpdateTable(dalForm.daadaptFlexibel, dsNew.Tbl_Flexibel)
UpdateTable(dalForm.daadaptFrontsteckmodul,
dsNew.Tbl_Front_St_Mdl)
'initSavedDetailsList()
'MsgBox("OK")
'Return dsNew
'End If
End Sub
Private Sub UpdateTable(ByVal daAdapt As Data.OleDb.OleDbDataAdapter,
ByVal dt As DataTable)
Dim ModifiedChildRecords As DataTable = dt
For Each ro As DataRow In dt.Rows
'MsgBox(ro.RowState)
Next
Try
If Not ModifiedChildRecords Is Nothing Then
daAdapt.Update(ModifiedChildRecords)
ModifiedChildRecords.Dispose()
End If
Catch ex As Exception
' Update error, resolve and try again
MsgBox("update Tab" + ex.Message + dt.TableName)
End Try
End Sub 5 1373
Hans,
From where you got that RunSQL I would expect OleDBcommand.executenonquery
As well is my idea the command to remove all rows "Delete Table", I am not
so sure however from Jet (access) in that..
While this one will probably as well don't do very much well.
ModifiedChildRecords.Dispose()
Or have you created your own wrapper and than we will find it of course
never.
I don't understand this.
Cor
..
"Hans Munich" <go****@munixmember.de> schreef in bericht
news:11*********************@g10g2000cwb.googlegro ups.com... Szenario:
User selects a XML File ("products.xml") to import newest Data. Data should replace Data in an existing Acess File which is connected via Dataadapter (daadaptFLR). Bevore the Existing Data are deleted with RunSQL("DELETE * From Tbl_Fl_Rundleitung").
Function the Works: If I copy the File from the directory of the Application.exe then it works fine.
Funktion Bugy: If I select the same file from another directory, the UpdateTable(dalForm.daadaptFLR, dsNew.Tbl_Fl_Rundleitung) Function fails. With following Error: Please remove Index or Constrains to prevent doubled Values. My Dataset seems to be loaded when i give it to a datagrid. And i can see a red attention hint with the same Error in first Line of Datagrid.
I'll be thankfull for any kind of Help.
Greetz from Munich Private Sub btOFD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOFD.Click Dim ofd As New OpenFileDialog ofd.ShowDialog() Try File.Copy(ofd.FileName, Application.StartupPath() + "\products.xml", True) pnStatus.BackColor = System.Drawing.Color.Green Catch ex As Exception pnStatus.BackColor = System.Drawing.Color.Red End Try End Sub
Private Sub checkGeneratedXML() Dim dsNew As New dsPreise Dim dsHolder As New dsPreise Dim fstream As FileStream Dim dalForm As New frmPreise
RunSQL("DELETE * From Tbl_Fl_Rundleitung") RunSQL("DELETE * From Tbl_Flexibel") RunSQL("DELETE * From Tbl_Front_St_Mdl") RunSQL("DELETE * From Tbl_Klm_Block") RunSQL("DELETE * From Tbl_Zubehoer")
'DAten aus XML einlesen dsNew.Clear() dsNew.ReadXml(Application.StartupPath() + "\products.xml") 'XmlReadMode.DiffGram , XmlReadMode.ReadSchema
dgLoadTEst.DataSource = dsNew
UpdateTable(dalForm.daadaptFLR, dsNew.Tbl_Fl_Rundleitung) UpdateTable(dalForm.daadaptFlexibel, dsNew.Tbl_Flexibel) UpdateTable(dalForm.daadaptFrontsteckmodul, dsNew.Tbl_Front_St_Mdl)
'initSavedDetailsList()
'MsgBox("OK") 'Return dsNew 'End If End Sub
Private Sub UpdateTable(ByVal daAdapt As Data.OleDb.OleDbDataAdapter, ByVal dt As DataTable) Dim ModifiedChildRecords As DataTable = dt For Each ro As DataRow In dt.Rows 'MsgBox(ro.RowState) Next Try If Not ModifiedChildRecords Is Nothing Then daAdapt.Update(ModifiedChildRecords) ModifiedChildRecords.Dispose() End If Catch ex As Exception ' Update error, resolve and try again MsgBox("update Tab" + ex.Message + dt.TableName) End Try
End Sub
What you are mssing is the following, and you are right.
But it isnt my Problem, i think. The Problem is that it works completly
with a file located in the same physikal directory as the executing
Application. If my importet .xml File first is copied from another
directory it fails.
Public Sub RunSQL(ByVal sql As String)
'SQL Befehl ausführen.
Dim conn As New OleDbConnection(DBConnectionString)
Dim adapter As New OleDbDataAdapter
Try
conn.Open()
adapter.InsertCommand = New OleDbCommand(sql, conn)
adapter.InsertCommand.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
MsgBox(sql + "---" + ex.Message)
End Try
End Sub
Hans,
You write that you read it from the application folder, how you do that from
another one?
dsNew.ReadXml(Application.StartupPath() + "\products.xml")
'XmlReadMode.DiffGram , XmlReadMode.ReadSchema
Cor
"Hans Munich" <go****@munixmember.de> schreef in bericht
news:11**********************@j33g2000cwa.googlegr oups.com...
What you are mssing is the following, and you are right.
But it isnt my Problem, i think. The Problem is that it works completly
with a file located in the same physikal directory as the executing
Application. If my importet .xml File first is copied from another
directory it fails.
Public Sub RunSQL(ByVal sql As String)
'SQL Befehl ausführen.
Dim conn As New OleDbConnection(DBConnectionString)
Dim adapter As New OleDbDataAdapter
Try
conn.Open()
adapter.InsertCommand = New OleDbCommand(sql, conn)
adapter.InsertCommand.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
MsgBox(sql + "---" + ex.Message)
End Try
End Sub
With the File Copy Function...
Private Sub btOFD_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btOFD.Click
Dim ofd As New OpenFileDialog
ofd.ShowDialog()
Try
File.Copy(ofd.FileName, Application.StartupPath() +
"\products.xml", True)
pnStatus.BackColor = System.Drawing.Color.Green
Catch ex As Exception
pnStatus.BackColor = System.Drawing.Color.Red
End Try
End Sub
Hans
Hans,
Are you sure you are not trying with this to copy the file to the area where
the enduser has no rights to do. I would just change the path where you are
reading and not use that application
startuppath.
This is normally the programdirectory Bin of your application, it should be
a closed area.
Just my idea
Cor
"Hans Munich" <go****@munixmember.de> schreef in bericht
news:11*********************@g10g2000cwb.googlegro ups.com... With the File Copy Function...
Private Sub btOFD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOFD.Click Dim ofd As New OpenFileDialog ofd.ShowDialog() Try File.Copy(ofd.FileName, Application.StartupPath() + "\products.xml", True) pnStatus.BackColor = System.Drawing.Color.Green Catch ex As Exception pnStatus.BackColor = System.Drawing.Color.Red End Try End Sub
Hans This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DraguVaso |
last post by:
Hi,
I should use XML to synchronize the data from different (VB.NET)
applications, and I was just wondering which Overloads of these functions
( ReadXmlSchema, ReadXml and WriteXml) goes the...
|
by: Nikhilesh Mehendale |
last post by:
I have written a web service in C#, .NET 1.1 which reads a XML file into a
dataset.
This is just a plain XML file. First I use the Dataset.ReadXmlScheme
function and pass the XML file to it. Then...
|
by: James Morton |
last post by:
I have a Static DataSet in a class file that I am using globally between a
few forms. The main form populates the dataset through a menu option which
invokes ReadXML in the class file to populate...
|
by: Steve |
last post by:
I've run across an issue that I'm trying to work around. I take that
back, I have a work around but I'm looking to see if anyone has a fix
for it.
The issue is that when loading a Boolean into a...
|
by: Raj Chudasama |
last post by:
I am trying to read an xml file and have it view data in the datagrid. (For
example take the xml file viewer in the visual studio, when u open an xml
file it has that nice readable grid).
I...
| |
by: C Glenn |
last post by:
I'm attempting to use ReadXml. It's working in that I end up with some
data in the DataSet. But I'm not able to deal with it effectively after
that. The XML file is properly formatted in that it...
|
by: ERingmae |
last post by:
Hi,
The environment is .NET 2.0, the language is C# and the problem is
reading XSD file with xs:redefine section correctly to a
XMLDataDocument.DataSet.
What I am trying to do:
I am trying...
|
by: =?Utf-8?B?QVRU?= |
last post by:
Hi,
I have an xml file that can contain a lot of records and I am using
dataset.readxml to read in the file. When looking on what I do with those
records, I am interested only the most recent...
|
by: Arto Viitanen |
last post by:
I am using WriteXML/ReadXml pair to save DataSet for later use. DataSet
is built by reading textfiles and storing their data to different
DataTables. Each file contains several complex values, that...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |