|
Public Sub saveBookingData()
Try
boolSave = False
Dim rsSave As New ADODB.Recordset
With rsSave
sSQL = "Select * From Student_tbl Where RegNo = '" & strEmpID & "' "
.Open(sSQL, cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
If .EOF Then
.AddNew()
rsSave.Fields("RegNo").Value = strEmpID
rsSave.Fields("Student_Name").Value = txtName.Text
rsSave.Fields("Father_Name").Value = txtFather.Text
rsSave.Fields("City_Name").Value = comCity.Text
.Update()
MessageBox.Show("Record Successfully Saved ", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Record Already Exist...", "Not Saved", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End With
Catch ex As Exception
MessageBox.Show(Err.Description)
End Try
End Sub
|
|
|
|
|
Yes, you can convert it. What is your question?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Converting old ADO code might not be very efficient; rewriting it to use a .NET DataProvider would not be very hard.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: ewriting it to use a .NET DataProvider Very much agreed.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
|
Public Sub saveBookingData()
Try
boolSave = False
Dim rsSave As New ADODB.Recordset
With rsSave
sSQL = "Select * From Student_tbl Where RegNo = '" & strEmpID & "' "
.Open(sSQL, cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
If .EOF Then
.AddNew()
rsSave.Fields("RegNo").Value = strEmpID
rsSave.Fields("Student_Name").Value = txtName.Text
rsSave.Fields("Father_Name").Value = txtFather.Text
rsSave.Fields("City_Name").Value = comCity.Text
.Update()
MessageBox.Show("Record Successfully Saved ", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Record Already Exist...", "Not Saved", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End With
Catch ex As Exception
MessageBox.Show(Err.Description)
End Try
End Sub
Love to Every One
|
|
|
|
|
hi. totally blind and use two screen readers, jaws for windows http://www.freedomscientific.com and non visual desktop access http://www.nvaccess.org. was rebuilding an old self talking hangman game, for a course i did for web design a few years ago, able to fix all the errors. using visual basic 2019 16.0.5 latest update. now, is there a tutorial or project, so i can then rebuild. also comes with sound effects. want to build this as a console. any update tutorials. if not self talking, then if so, then how to choose the voices and how to get it to talk. have all the latest vocaliser voices from nuance, and also the windows 10 mobile voices and sapi voices version 5. any one happen to point me to a tutorial. so then i can then rebuild and code and then use the latest talking voices and also have my sound effects, run in the game. did run my app, but says cannot find the directory for some files, and if i try to rebuild again, with original code, then get errors, which cannot seem to fix. and did google, but still did not find any thing. any one able to help me out and point me to where i can find one. have tried googling. did find one for pc_games for the blind, but no links, to the game. any help and in australia. thanks.,,,
|
|
|
|
|
Not sure if this is a language/age gap, but I think this post is mostly going to be considered a spam.
You have not explained the problem, and not shown the effort made by you. So try to explain and describe your situation here.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
hi, well pasting my code and errors below. no sniping or snide remarks. help me out with my errors, and a better way to get this to work please. will paste my code and then my errors. thanks. ps: pasting now.
Imports System.IO
Imports System.Media
Imports System.Speech.Synthesis
Imports System.Windows.Forms
' Program: Hangman
' Author: Marvin Hunkin
' Version: 1.1
' Date: Tuesday December 25, 2012
' Description: Playing a Hangman game. You enter a letter to use a list of words loaded into memory. You then guess a six letter word, and use 13 guesses. At the end of 13 guesses, you get a message saying you either won or loss, and what the word was, and a number to exit the game being 1. Added a couple of cool sound audio effects.
Module Module1
' Declare class level variables
Dim WordMask As String = "------"
Dim WordArray() As String
Dim Talker As New SpeechSynthesizer
Dim Player As New SoundPlayer
Sub Main()
' Create a new wordlist file path
Dim wordlistPath = Path.Combine(Application.StartupPath, "Resources", "wordlist.txt")
' Populate the word array variable with the contents of the file path
WordArray = File.ReadAllLines(wordlistPath)
' Show the window maximized and show the name of the application in the title bar
Console.WindowWidth = 60
Console.Title = "Hangman"
Dim NewUri As Uri = Nothing
Dim Result As Boolean = Uri.TryCreate(Directory.GetParent(Directory.GetCurrentDirectory).Parent.ToString + "\en-sc", UriKind.Absolute, NewUri)
If Result Then
Talker.AddLexicon(NewUri, SynthesisMediaType.Ssml)
Talker.SelectVoice(0)
End If
' Welcome message
Console.WriteLine("Welcome To Hangman!")
SpeakLines("Welcome To Hangman!")
Console.WriteLine("This game is to be played by blind and visually impaired players.")
SpeakLines("This game is to be played by blind and visually impaired players.")
Console.WriteLine()
' Declare local variables
Dim ContinuePlayingGames As Boolean = True
' While loop to play the game
While ContinuePlayingGames
PlaySound("Futile02.wav")
Dim RandomIndex As Integer = GetRandom(0, (WordArray.Length - 1))
Dim PickedWord As String = WordArray(RandomIndex)
PlayAGame(PickedWord)
Dim QuitRequested As String
Console.WriteLine("Enter 1 to quit playing or Press Enter to play again")
Console.WriteLine()
SpeakLines("Enter 1 to quit playing or Press Enter to play again")
QuitRequested = Console.ReadLine()
If QuitRequested = "1" Then
PlaySound("discon.wav")
Console.WriteLine("Goodbye")
SpeakLines("Goodbye")
Exit While
Else
Console.Clear()
End If
End While
Dim CloseRequested As String
Console.WriteLine("Hit any key to close console.")
Console.WriteLine()
SpeakLines("Hit any key to close console.")
CloseRequested = Console.ReadLine()
End Sub
' Function to get the mask for the game
Private Function RenderMask(ByVal Str As String) As String
' Declare local variables
Dim temp As String = ""
For Each Letter As Char In Str
If Letter = "-" Then
temp += "dash"
Else
temp += "the letter " & Letter
End If
temp += ", "
Next
Return temp
End Function
' Function to speak lines in the Microsoft Samantha voice
Private Sub SpeakLines(ByVal Str As String)
End Sub
' Sub to play sounds for the game
Private Sub PlaySound(ByVal Sound As String)
' Get the sounds and stream it to the game
Player.Stream = File.OpenRead(Path.Combine(Application.StartupPath, "Resources", Sound + ".wav"))
Player.PlaySync()
Player.Stream.Dispose()
End Sub
' Play A Game Sub starts here
Private Sub PlayAGame(ByVal PassedWord As String)
' Declare local variables
Dim EnteredLetter As String = ""
Dim MatchedLetterCount As Integer = 0
' For loop to guess 1 to 13 moves
Dim GuessCount As Integer = 0
Dim TempMask As String = ""
For GuessCount = 1 To 13
Console.WriteLine(WordMask)
SpeakLines("So far you have " & RenderMask(WordMask))
Console.WriteLine("Guess Number - " + GuessCount.ToString + ", Enter A Letter")
Console.WriteLine()
SpeakLines("Guess Number - " + GuessCount.ToString + ", Enter A Letter")
EnteredLetter = Console.ReadLine()
SpeakLines("You entered the letter " & EnteredLetter)
PlaySound("LaserBeamHit.wav")
If EnteredLetter <> "2"(0) Then
TempMask = WordMask
MatchedLetterCount = CheckEnteredLetter(PassedWord, EnteredLetter, MatchedLetterCount)
If TempMask <> WordMask Then
GuessCount -= 1
End If
If MatchedLetterCount = 6 Then
PlaySound("Bugle Reveille.wav")
Console.WriteLine("You Win!")
SpeakLines("You Win!")
Console.WriteLine("The word was " & WordMask)
SpeakLines("The word was " & WordMask)
WordMask = "------"
Exit For
End If
Else
ShowMessage()
GuessCount -= 1
End If
Next GuessCount
Console.WriteLine("Sorry, you used up all 13 guesses, you lose!")
SpeakLines("Sorry, you used up all 13 guesses, you lose!")
Console.WriteLine("The word was " & PassedWord)
SpeakLines("The word was " & PassedWord)
WordMask = "------"
End Sub
' Sub to show the message in the game
Private Sub ShowMessage()
' Declare local variables
Dim Title As String = "Program: Hangman."
Dim MessageString As String = " Author : Marvin Hunkin." + vbNewLine + "Version: 1.1." + vbNewLine + "Date: Tuesday December 25, 2012." + vbNewLine + "Description: Playing a Hangman game." + vbNewLine + "You enter a letter to use a list of words loaded into memory." + vbNewLine + "You then guess a six letter word, and use 13 guesses." + vbNewLine + "At the end of 13 guesses, you get a message saying you either won or loss," + vbNewLine + " and what the word was, and a number to exit the game being 1." + vbNewLine + "Added a couple of cool sound audio effects." + vbNewLine + "Press Enter to Continue."
Talker.Speak(Title)
Talker.SpeakAsync(MessageString)
' Show Messages for this sub
MessageBox.Show(MessageString, Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
Talker.SpeakAsyncCancelAll()
End Sub
' Function to check the letter for the game
Private Function CheckEnteredLetter(ByVal PassedWord As String, ByVal PassedLetter As String, ByVal PassedMatchedLetterCount As Integer) As Integer
' for loop to check that you entered up to 6 letters
For ndx As Integer = 0 To 5
If PassedWord(ndx) = PassedLetter Then
PassedMatchedLetterCount += 1
Mid(WordMask, ndx + 1) = PassedLetter
End If
Next ndx
Return PassedMatchedLetterCount
End Function
' Public function to get the random number selected for the game
Public Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer
' Declare variables
Dim Generator As System.Random = New System.Random()
' Return Generator random value for the game
Return Generator.Next(Min, Max)
End Function
End Module and here's the errors. how to fix. and a better way to do this. and got my Resources folder with the sound effects and the list of radnom letters in a text file. any help.
Severity Code Description Project File Line Suppression State
Message IDE0059 Value assigned to 'TempMask' is never used HangMan E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb 129 Active
Message IDE0044 Make field readonly HangMan E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb 18 Active
Message IDE0044 Make field readonly HangMan E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb 19 Active
Message IDE0060 Remove unused parameter 'Str' HangMan E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb 102 Active
Message IDE0059 Value assigned to 'EnteredLetter' is never used HangMan E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb 123 Active
Message IDE0059 Value assigned to 'GuessCount' is never used HangMan E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb 128 Active
|
|
|
|
|
Those are not errors. They are warnings. All they are saying is that you declared these variables, may you set values for them, but never used the values anywhere.
Anyway, I copied your code into a new Windows Forms and compiled it. I didn't get the warnings you're talking about.
|
|
|
|
|
hi, this is a console app. so did your win forms project work, if so, then fine, can you send me the project, via e-mail to me as a zip, so then i can then rebuild the windows forms. just did not get any errors. and said it did not build, from my external drive. able to do this for me dave. marvin.
|
|
|
|
|
I didn't do anything special at all.
All I did was apparently what you did. Since you have a reference to "System.Windows.Forms" near the top of the code, that tells me you added a Module to a new Windows Forms project, and then added your code to the new Module. You then changed the project Startup to either "Sub Main" or "Module1" in the Project Properties.
Again, those are not errors. Everything you posted is a Warning and will not, by default, prevent your code from compiling and running. Unless, of course, you turned on the option that says "Treat warnings as errors".
|
|
|
|
|
hi. so can you e-mail me privately and help me out, then i can then e-mail you back and forth. so, then how to fix this and my screen reader jaws says build failed. no, did not turn any thing on. so, how to fix this, and then get this to build. it is a console app. unless try creating a new console app, then maybe not add the windows forms. can you help. thanks.
|
|
|
|
|
I told you exactly what I did you recreate your project. You can go through the exact same steps to do it yourself. It'll take you 2 minutes.
Start with a new Windows Forms app, add a new Module file to it, and copy your exact code from your own post into that Module file.
Oh, and you're going to have to add a reference to System.Speech.
|
|
|
|
|
You need to be clear on what you are asking. And no, it is unlikely anyone will fix it for you and email you back all the fixed code. Unless you pay.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I tried to solve this and did not get it, the problem that I have a MatLab DLL file with a function looks like this
[tmin, mawp,sigma,tmin_c,tmin_l,segma_c,segma_l] = cylindrical(a,b,c,d,e,f)
I did reference the dll and the mwarray dll, when I call the MatLab's obj to the function it returns nothing, and if I use an index to map the array it gives an invalid index error. I am sorry if I didn't make myself clear, but I hope the code will.
This is VB.NET program that uses Matlab function to calculate some values, I tried to make the output as an array using ToArray function but it didn't work, Also in the MathWork documentation they talked about that conversion as in vb you need to use op_implicit function but I did not figure it out, I tried so many things but I am stuck here guys, appreciate your help.
'after importing dlls
Dim matlab As MAWP_CYL = New MAWP_CYL()
'this to matlab obj
Dim result = matlab.Cylindrical(1,1,1,1,1,1).ToArray()
'using any numbers for test
'here result have nothing when debugging,
the result has nothing, not an array or any form of lists.
|
|
|
|
|
What are the parameter values to the Cylindrical function supposed to be, and what result should it return?
|
|
|
|
|
Hello all.
Does anyone know how to send multiple latitudes & longitudes from VB.net to Google Maps and receive from Maps services what is the best route?
I'd like to receive something like this:
1) Address B
2) Address A
3) Address D
4) Address C
It would indicate me where to go first.
Thanks.
Paulo
|
|
|
|
|
Ah the old drunkards walk - I designed one of these in the 90s, for just one city. I'm betting Google does not have such a facility freely available, it is a MAJOR task to get right as you must take into account one way street and traffic conditions.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
The API accepts multiple addresses, and returns the results in the form of arrays. The actual format to be used will depend on which version (iOS, Android, JSON) that you are using. The Google documentation should help.
|
|
|
|
|
I posted this C# board first which was a mistake again I apologize. I work for this company where the old programmer was in the process of rewrite the source code with no documentation at all from VB.Net to C# Now we have 4 programs total and they all update from the same database and get price updates on items. My problem is on one of the programs if a customer was to do full sync which is the whole database list of well 60,000 items I get OutOfMemoryException when it imports the last category Items. Here are the Exceptions Quote: Exception thrown: 'System.OutOfMemoryException' in System.Data.dll
Exception thrown: 'System.OutOfMemoryException' in Microsoft.EntityFrameworkCore.Relational.dll
Exception thrown: 'System.OutOfMemoryException' in Microsoft.EntityFrameworkCore.Relational.dll
Exception thrown: 'System.OutOfMemoryException' in Microsoft.EntityFrameworkCore.dll
Exception thrown: 'System.OutOfMemoryException' in Microsoft.EntityFrameworkCore.dll
Private Function DoImpItems() As Boolean
Dim percent As Integer = 0
Dim currentRow As Integer = 0
Dim ItemDataRow As DataSetPricing.ItemsRow
Dim CommodityDataRow As DataSetPricing.CommoditiesRow
Dim LevelTypeDataRow As DataSetPricing.LevelTypesRow
Dim StatusDataRow As DataSetPricing.StatusRow
Dim ManufacturerDataRow As DataSetPricing.ManufacturersRow
Dim UomDataRow As DataSetPricing.UOMRow
Dim WorkgroupDataRow As DataSetPricing.WorkGroupsRow
Dim Item As Models.Item
Manufacturers = ServiceLocator.Current.GetInstance(Of IManufacturers).Get
WorkGroups = ServiceLocator.Current.GetInstance(Of IWorkgroups).Get
LevelTypes = ServiceLocator.Current.GetInstance(Of ILevelTypes).Get
ItemStatus = ServiceLocator.Current.GetInstance(Of IItemStatusTypes).Get
UOM = ServiceLocator.Current.GetInstance(Of IUom).Get
'Update Existing Items
Try
currentRow = 0
For Each row In DataSetPricing.Items
Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(row.RowID)
If Not Item Is Nothing Then
If Not Item.DoNotUpdate Then
Item.EriNumber = row.ERINumber
Item.EriNumberSearch = row.ERINumber
Item.Comparative = row.Comparative
If row.ParentID <> 0 Then
ItemDataRow = DataSetPricing.Items.Where(Function(d) d.PK_ItemID = row.ParentID).SingleOrDefault
If Not ItemDataRow Is Nothing Then
Dim ItemParent As Models.Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(ItemDataRow.RowID)
If Not ItemParent Is Nothing Then
Item.ParentId = ItemParent.PkItems
Else
Item.ParentId = 0
End If
Else
Item.ParentId = 0
End If
Else
Item.ParentId = 0
End If
Item.CatalogNumber = row.CatalogNumber
Item.Description = row.Description
Item.MyCost = CDec(Math.Round(row.Cost * IIf(IsDBNull(Item.MyMultiplier), 1, Item.MyMultiplier), 2))
Item.Cost = row.Cost
Item.Retail = row.Retail
If Not Config.NoUpdateLabor Then
Item.Labor = row.Labor
End If
Item.EffectiveDate = row.DateEffective
Item.Comparative = row.Comparative
Item.UPC = Strings.Right(row.UPC, 5)
Item.AlphaIndex = row.AlphaIndex
Item.ReportGroup = row.ReportGroup
Item.ImKing = row.ImKing
Item.ImageUrl = IIf(IsDBNull(row.ImageURL), String.Empty, row.ImageURL)
Item.CatalogPageUrl = IIf(IsDBNull(row.CatalogPageURL), String.Empty, row.CatalogPageURL)
Item.LastCostUpdate = Date.Now
LevelTypeDataRow = DataSetPricing.LevelTypes.Where(Function(d) d.PK_LevelTypeID = row.FK_LevelTypeID).SingleOrDefault
If Not LevelTypeDataRow Is Nothing Then
Dim q = (From c In LevelTypes Where c.RowId = LevelTypeDataRow.RowID).SingleOrDefault
Item.FkLevel = q.LevelTypeId
Else
Item.FkLevel = 1
End If
StatusDataRow = DataSetPricing.Status.Where(Function(d) d.PK_StatusID = row.FK_StatusID).SingleOrDefault
If Not StatusDataRow Is Nothing Then
Dim q = (From c In ItemStatus Where c.Status = StatusDataRow.Description).SingleOrDefault
Item.FkStatus = q.PkItemStatusTypes
Else
Item.FkStatus = 1
End If
UomDataRow = DataSetPricing.UOM.Where(Function(d) d.PK_UOMID = row.FK_UOMID).SingleOrDefault
If Not UomDataRow Is Nothing Then
Dim q = (From c In UOM Where c.UOM = UomDataRow.ShortDescription).SingleOrDefault
Item.FkUom = q.IdUom
Else
Item.FkUom = 0
End If
WorkgroupDataRow = DataSetPricing.WorkGroups.Where(Function(d) d.PK_WorkGroupID = row.FK_WorkgroupID).SingleOrDefault
If Not WorkgroupDataRow Is Nothing Then
Dim q = (From c In WorkGroups Where c.RowId = WorkgroupDataRow.RowID).SingleOrDefault
Item.FkWorkgroup = q.PkWorkgroups
Else
Item.FkWorkgroup = 0
End If
CommodityDataRow = DataSetPricing.Commodities.Where(Function(d) d.PK_CommodityID = row.FK_CommodityID).SingleOrDefault
If Not CommodityDataRow Is Nothing Then
Dim q = ServiceLocator.Current.GetInstance(Of ICommodities).GetByRowId(CommodityDataRow.RowID)
Item.FkCommodityId = q.PkCommodityId
Else
Item.FkCommodityId = 0
End If
ManufacturerDataRow = DataSetPricing.Manufacturers.Where(Function(d) d.PK_ManufacturerID = row.FK_ManufacturerID).SingleOrDefault
If Not ManufacturerDataRow Is Nothing Then
Dim q = (From c In Manufacturers Where c.RowId = ManufacturerDataRow.RowID).FirstOrDefault
Item.FkManufacturer = q.PkManufacturerId
Else
Item.FkManufacturer = 0
End If
End If
ServiceLocator.Current.GetInstance(Of IItems).Update(Item)
Else
Dim entity As New Models.Item
entity.EriNumber = row.ERINumber
entity.EriNumberSearch = row.ERINumber
entity.CatalogNumber = row.CatalogNumber
entity.Description = row.Description
entity.MyCost = row.Cost
entity.Cost = row.Cost
entity.Retail = row.Retail
entity.Labor = row.Labor
entity.EffectiveDate = row.DateEffective
entity.Comparative = row.Comparative
entity.UPC = Strings.Right(CStr(row.UPC), 5)
entity.AlphaIndex = row.AlphaIndex
entity.ReportGroup = row.ReportGroup
entity.ImKing = row.ImKing
entity.MyMultiplier = 1
entity.RowId = row.RowID
entity.ImageUrl = row.ImageURL
entity.CatalogPageUrl = row.CatalogPageURL
entity.LastCostUpdate = Date.Now
entity.DefaultCostCode = 0
If row.ParentID <> 0 Then
ItemDataRow = DataSetPricing.Items.Where(Function(d) d.PK_ItemID = row.ParentID).SingleOrDefault
If Not ItemDataRow Is Nothing Then
Dim ItemParent As Models.Item = ServiceLocator.Current.GetInstance(Of IItems).GetByRowId(ItemDataRow.RowID)
If Not ItemParent Is Nothing Then
entity.ParentId = ItemParent.PkItems
Else
entity.ParentId = 0
End If
Else
entity.ParentId = 0
End If
Else
entity.ParentId = 0
End If
LevelTypeDataRow = DataSetPricing.LevelTypes.Where(Function(d) d.PK_LevelTypeID = row.FK_LevelTypeID).SingleOrDefault
If Not LevelTypeDataRow Is Nothing Then
Dim q = (From c In LevelTypes Where c.RowId = LevelTypeDataRow.RowID).SingleOrDefault
entity.FkLevel = q.LevelTypeId
Else
entity.FkLevel = 1
End If
StatusDataRow = DataSetPricing.Status.Where(Function(d) d.PK_StatusID = row.FK_StatusID).SingleOrDefault
If Not StatusDataRow Is Nothing Then
Dim q = (From c In ItemStatus Where c.Status = StatusDataRow.Description).SingleOrDefault
entity.FkStatus = q.PkItemStatusTypes
Else
entity.FkStatus = 1
End If
UomDataRow = DataSetPricing.UOM.Where(Function(d) d.PK_UOMID = row.FK_UOMID).SingleOrDefault
If Not UomDataRow Is Nothing Then
Dim q = (From c In UOM Where c.UOM = UomDataRow.ShortDescription).SingleOrDefault
entity.FkUom = q.IdUom
Else
entity.FkUom = 0
End If
WorkgroupDataRow = DataSetPricing.WorkGroups.Where(Function(d) d.PK_WorkGroupID = row.FK_WorkgroupID).SingleOrDefault
If Not WorkgroupDataRow Is Nothing Then
Dim q = (From c In WorkGroups Where c.RowId = WorkgroupDataRow.RowID).SingleOrDefault
entity.FkWorkgroup = q.PkWorkgroups
Else
entity.FkWorkgroup = 0
End If
CommodityDataRow = DataSetPricing.Commodities.Where(Function(d) d.PK_CommodityID = row.FK_CommodityID).SingleOrDefault
If Not CommodityDataRow Is Nothing Then
Dim q = ServiceLocator.Current.GetInstance(Of ICommodities).GetByRowId(CommodityDataRow.RowID)
entity.FkCommodityId = q.PkCommodityId
Else
entity.FkCommodityId = 0
End If
ManufacturerDataRow = DataSetPricing.Manufacturers.Where(Function(d) d.PK_ManufacturerID = row.FK_ManufacturerID).SingleOrDefault
If Not ManufacturerDataRow Is Nothing Then
Dim q = (From c In Manufacturers Where c.RowId = ManufacturerDataRow.RowID).FirstOrDefault
entity.FkManufacturer = q.PkManufacturerId
Else
entity.FkManufacturer = 0
End If
ServiceLocator.Current.GetInstance(Of IItems).Add(entity)
End If
currentRow += 1
percent = CInt((currentRow / DataSetPricing.Items.Rows.Count) * 100)
BackgroundWorker.ReportProgress(percent)
Next
Catch ex As Exception
secondLevelMsg = ex.Message
Return False
Exit Function
End Try
Return True
End Function
|
|
|
|
|
Looks to me "it" is reading, updating and creating (Entity Framework) entities; but nowhere is it writing ("flushing") these entities to a database or garbage collecting. So, "memory" just fills up.
This may work for a few items (for whatever purpose), but not apparently for "60,000" (at one time).
For Each row In DataSetPricing.Items
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
What about using
XStreamingElement When reading the file
DataSetPricing.Items.BeginLoadData()
DataSetPricing.Items.DataSet.ReadXml(String.Format("{0}\Items.xml", My.Computer.FileSystem.SpecialDirectories.Temp), XmlReadMode.InferTypedSchema)
DataSetPricing.Items.EndLoadData()
BackgroundWorker.ReportProgress(60)
How do I change the code?
|
|
|
|
|
I'm trying to read an xml file one line at a time to update someone database with our prices tell me am I on the right path:
Private Sub TestReader()
Dim reader As XmlReader = XmlReader.Create(String.Format("{0}\Items.xml", My.Computer.FileSystem.SpecialDirectories.Temp))
reader.MoveToContent()
While reader.Read
If reader.NodeType = XmlNodeType.Element And reader.Name = "Items" Then
Dim row As DataSetPricing.ItemsRow = New DataSetPricing.ItemsDataTable().NewItemsRow
While reader.Read
If reader.NodeType = XmlNodeType.Element Then
Dim element As XElement = XElement.ReadFrom(reader)
Select Case reader.Name
Case "PK_ItemID"
row.PK_ItemID = element.Value
Exit Select
Case "ParentID"
row.ParentID = element.Value
Exit Select
Case "ERINumber"
row.ERINumber = element.Value
Exit Select
Case "Comparative"
row.Comparative = element.Value
Exit Select
Case "AlphaIndex"
row.AlphaIndex = element.Value
Exit Select
Case "Description"
row.Description = element.Value
Exit Select
Case "ImKing"
row.ImKing = element.Value
Exit Select
Case "FK_ManufacturerID"
row.PK_ItemID = element.Value
Exit Select
Case "FK_StatusID"
row.FK_StatusID = element.Value
Exit Select
Case "FK_LevelTypeID"
row.FK_LevelTypeID = element.Value
Exit Select
Case "FK_WorkGroupID"
row.FK_WorkgroupID = element.Value
Exit Select
Case "FK_CommodityID"
row.FK_CommodityID = element.Value
Exit Select
Case "UPC"
row.CatalogNumber = element.Value
Exit Select
Case "FK_UOMID"
row.FK_UOMID = element.Value
Exit Select
Case "Retail"
row.Retail = element.Value
Exit Select
Case "Cost"
row.Cost = element.Value
Exit Select
Case "Labor"
row.Labor = element.Value
Exit Select
Case "Multiplier"
row.Multiplier = element.Value
Exit Select
Case "ReportGroup"
row.ReportGroup = element.Value
Exit Select
Case "DateEffective"
row.DateEffective = element.Value
Exit Select
Case "ImageURL"
row.ImageURL = element.Value.ToString
Exit Select
Case "CatalogPageURL"
row.CatalogPageURL = element.Value.ToString
Exit Select
Case "LastUpdateDateTime"
row.LastUpdateDateTime = element.Value
Exit Select
Case "RowID"
row.RowID = element.Value
Exit Select
End Select
End If
End While
End If
End While
End Sub
|
|
|
|
|
Hi,
i want to create an option when I click right on 2 files.
I added the regkey in HKCU\Software\Classes*\shell and command.
but when I select my option it is executed twice. Once on file 1 and once on file 2. I want to run the command on the 2 files at once so that I can check that there are exactly 2 files selected as a parameter and than I can do my stuff with those files.
How can I make windows run my command on the 2 files in 1 instance of my command?
Jan
|
|
|
|
|