please any one tel me what is wrong i try to read an xml file to dataset and update an table on my database
her is my code
her is my code
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ds [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet, Sql [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2], cmd [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlClient.SqlCommand[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dv [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataView[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dai [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlClient.SqlDataAdapter([/SIZE][SIZE=2][COLOR=#800000]"select * from Items"[/COLOR][/SIZE][SIZE=2], db)[/SIZE]
[SIZE=2][COLOR=#008000]'dai.Fill(ds, "Items")[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'ds.WriteXml(My.Application.Info.DirectoryPath & "\items.xml", XmlWriteMode.WriteSchema)[/COLOR][/SIZE]
[SIZE=2]ds = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] System.IO.File.Exists([/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Application.Info.DirectoryPath & [/SIZE][SIZE=2][COLOR=#800000]"\items.xml"[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2]ds.ReadXml([/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Application.Info.DirectoryPath & [/SIZE][SIZE=2][COLOR=#800000]"\items.xml"[/COLOR][/SIZE][SIZE=2], XmlReadMode.InferSchema)[/SIZE]
[SIZE=2]dv = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataView(ds.Tables(0))[/SIZE]
[SIZE=2][COLOR=#008000]'Dim dbb As New SqlClient.SqlBulkCopy(db)[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'dbb.DestinationTableName = "dbo.items"[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]'dbb.WriteToServer(ds.Tables(0))[/COLOR][/SIZE]
[SIZE=2]cmd.Connection = db[/SIZE]
[SIZE=2]cmd.CommandText = [/SIZE][SIZE=2][COLOR=#800000]"INSERT INTO [dbo].[Items]"[/COLOR][/SIZE][SIZE=2] _[/SIZE]
[SIZE=2]& [/SIZE][SIZE=2][COLOR=#800000]" ([ItmCode],[ItmBarCode],[ItmArabName],[ItmEngName],[ItmPrice1],[ItmPrice2]"[/COLOR][/SIZE][SIZE=2] _[/SIZE]
[SIZE=2]& [/SIZE][SIZE=2][COLOR=#800000]" ,[ItmPrice3],[ItmPack],[ItmUnit],[ItmUnitQuantity],[ItmAverageCost],[ItmLastCost],[ItmOldAvrage])"[/COLOR][/SIZE][SIZE=2] _[/SIZE]
[SIZE=2]& [/SIZE][SIZE=2][COLOR=#800000]" values (@ItmCode,@ItmBarCode,@ItmArabName,@ItmEngName,@ItmPrice1,@ItmPrice2,@ItmPrice3,"[/COLOR][/SIZE][SIZE=2] _[/SIZE]
[SIZE=2]& [/SIZE][SIZE=2][COLOR=#800000]" @ItmPack,@ItmUnit,@ItmUnitQuantity,@ItmAverageCost,@ItmLastCost, @ItmOldAvrage) "[/COLOR][/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmCode"[/COLOR][/SIZE][SIZE=2], SqlDbType.NVarChar, 25, [/SIZE][SIZE=2][COLOR=#800000]"ItmCode"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@itmBarCode"[/COLOR][/SIZE][SIZE=2], SqlDbType.NVarChar, 20, [/SIZE][SIZE=2][COLOR=#800000]"itmbarcode"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmArabName"[/COLOR][/SIZE][SIZE=2], SqlDbType.NVarChar, 150, [/SIZE][SIZE=2][COLOR=#800000]"ItmarabName"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmEngName"[/COLOR][/SIZE][SIZE=2], SqlDbType.NVarChar, 150, [/SIZE][SIZE=2][COLOR=#800000]"ItmEngName"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmUnitQuantity"[/COLOR][/SIZE][SIZE=2], SqlDbType.Float, 8, [/SIZE][SIZE=2][COLOR=#800000]"ItmUnitQuantity"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmPrice1"[/COLOR][/SIZE][SIZE=2], SqlDbType.Float, 8, [/SIZE][SIZE=2][COLOR=#800000]"ItmPrice1"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmPrice2"[/COLOR][/SIZE][SIZE=2], SqlDbType.Float, 8, [/SIZE][SIZE=2][COLOR=#800000]"ItmPrice2"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmPrice3"[/COLOR][/SIZE][SIZE=2], SqlDbType.Float, 8, [/SIZE][SIZE=2][COLOR=#800000]"ItmPrice3"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmPack"[/COLOR][/SIZE][SIZE=2], SqlDbType.SmallInt, 4, [/SIZE][SIZE=2][COLOR=#800000]"ItmPack"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmUnit"[/COLOR][/SIZE][SIZE=2], SqlDbType.NVarChar, 20, [/SIZE][SIZE=2][COLOR=#800000]"ItmUnit"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmAverageCost"[/COLOR][/SIZE][SIZE=2], SqlDbType.Float, 8, [/SIZE][SIZE=2][COLOR=#800000]"ItmAverageCost"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmLastCost"[/COLOR][/SIZE][SIZE=2], SqlDbType.Money, 8, [/SIZE][SIZE=2][COLOR=#800000]"ItmLastCost"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]cmd.Parameters.Add([/SIZE][SIZE=2][COLOR=#800000]"@ItmOldAvrage"[/COLOR][/SIZE][SIZE=2], SqlDbType.Money, 8, [/SIZE][SIZE=2][COLOR=#800000]"ItmOldAvrage"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] lm [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = ds.Tables([/SIZE][SIZE=2][COLOR=#800000]"items"[/COLOR][/SIZE][SIZE=2]).Rows.Count[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] da [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlClient.SqlDataAdapter[/SIZE]
[SIZE=2][COLOR=#008000]'da.Fill(ds)[/COLOR][/SIZE]
[SIZE=2]da.TableMappings.Add([/SIZE][SIZE=2][COLOR=#800000]"Items"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"Items"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]da.AcceptChangesDuringUpdate = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[SIZE=2]da.InsertCommand = cmd[/SIZE]
[SIZE=2]da.Update(ds.Tables(0))[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]