|
>>VB still didn't send that clause. It took my hardcoded front half ("Select From Where") plus the following AND condition successfully. But completely skipped DateTime.
Ok. it sounds like your doing everything right.
Last ditch effort: put a breakpoint on the FillByWhere function (assuming your following the article logic closely). Check the value on the WhereExp variable. What is the exact string after this line has run: "Me._commandCollection(0).CommandText += " WHERE " + WhereExp"?
That should be exactly what's being sent to the db. If the value is wrong there, press CTRL+L and go up the call stack to see where the value is being excluded.
Good luck~!
|
|
|
|
|
Yes! Thank you. I didn't know about SQL Profiler and since I've been watching that has pinpointed the problem. My textbox input data had an extra pair of ''s
Result:
SELECT * from Route_Call_Detail where RouterCallKeyDay > 148875 AND DateTime > ''2008-08-14 06:38:42.153''
It's corrected and I'm on my merry way.
|
|
|
|
|
|
To whom ever can guide me a little on file stream usage.
I have a decent number of binary files that I must read only the first line of. Normally I declare a filestream as such (and use a binaryreader to use the filestream):
Dim fs As New FileStream(strFile(0), FileMode.Open, FileAccess.Read)
Is there a way to change the source file dynamically, or do I have to declare a new file stream for each file? The Name property is read only.
Thanks!
|
|
|
|
|
Come fellow code project alumni - show thee the light!
|
|
|
|
|
Try this...
Dim fs as FileStream
Dim FilesToProcess as New List(Of String)
FilesToProcess.Add("c:\test.txt")
FilesToProcess.Add("C:\boot.ini")
For Each fileToProcess as String in FilesToProcess
fs = New FileStream(strFile, FileMode.Open, FileAccess.Read)
'TODO: whatever you need to do with the file
Next 'filetoProcess
|
|
|
|
|
You're still declaring a new FileStream for each file.
|
|
|
|
|
no, just reallocating the one that has already been instantiated.
It sounded like he was trying to avoid doing this...
Dim fs1 as New FileStream(file1,blah, blah)
Dim fs2 as New FileStream(file2,blah, blah)
Dim fs3 as New FileStream(file3,blah, blah)
KissDzNutz, remember not to instantiate (Dim as New) inside the loop. Its less expensive to keep using the same ref.
|
|
|
|
|
Initially your suggestion is what I was doing with in a for loop of the directories, but I changed the code as such (basic version, there is more work occurring after the last using with the byte array):
strEnum = strFile.GetEnumerator
While strEnum.MoveNext
Using fs As New FileStream(strEnum.Current.ToString, FileMode.Open, IO.FileAccess.Read)
Using br As New BinaryReader(fs)
bytLine = br.ReadBytes(55)
fs.Flush() : fs.Close()
br.Close()
End Using 'br
End Using 'fs
end while
What are the performance differences to using the above vs. fs = new file stream within the loop? For example, if the loop ran 20x, would there be 19 dead variables that .dispose can't be used on?
Also, since I'm being schooled today , I have another dumb question regarding the "new" keyword for declaring new vars in a specific way.
For a simple example, creating the following string var is set up to *****
Dim strTest As String = "*****"
Creating the variable below accomplishes the same thing, but when you use the = New String part, does this actually create 2 string variables (meaning strTest and then a new string that is floating around in deep space)?
Dim strTest As String = New String(CChar("*"), 5)
Thanks! Always trying to learn...
|
|
|
|
|
Eek... whoever taught you to use .GetEnumerator and MoveNext to iterate a string collection (array, or ListOf) should be shot. That, along with "If (Not Is Nothing)" is easily confusing and difficult for the next person to follow. For Loops are the way to go.
To answer your first question, Yes. You will have paid the setup, instantiation, and destruction costs 20x. You can call .Dispose() manually if you want to, but you are essentially discarding the memory to the GC by not using the object any longer.
When you declare a variable with "Dim obj as New Object()" (or with Using), you are basically allocating a chunk of memory and filling it (instantiation). The application will have to manage that object and clean up after it (Creation and Destruction), so each of the 3 operations (allocate / create, instantiate, destroy) has a resource cost.
If you declare a variable with "Dim obj as Object", you are only doing the allocation of memory. You can then re-use that referenced memory (obj = New Object()) to repeatedly instantiate objects and only pay the Creation cost 1x. Yes you will still have to pay instantiation and destruction costs, but this will save you some cost.
This works for reference types, since value types are created right on the heap I dont think it makes a lick of difference.
Strings are immutable, which means that each change creates more memory.
Dim str1 as String = "abc" 'one object in memory
Dim str2 as String = str1 + "def" 'now there are 3 objects in memory. str1, "def", and str2.
This is why they made StringBuilder classes. These are able to properly append and not make so many objects in memory.
|
|
|
|
|
Thanks for the responses.
|
|
|
|
|
No. You are only declaring one strFile and re-using it like I explained in the middle of the last post.
If you want, you can also do
For x as Integer = 0 to strFiles.Length -1
'do operations with strFiles(x)
Next 'x
Strings being immutable refers to the fact that they cannot be changed. New ones are created and replace the last one.
1K strings is really not a lot and either method would work well. You will see object creation cost saving benefits when dealing with larger and more complex objects (like Streams/ UI Controls, iTextSharp PDF objects).
|
|
|
|
|
Just a couple small things I have wondered about and never really found concrete answers for.
Thanks for taking the time and giving full explanations.
|
|
|
|
|
I want to connect to an access database using vb.net. Can someone kindly assist with the codes to do this, including the declaration codes as well. I want to connect using codes and not the datagrid.
Thank you!
|
|
|
|
|
There is nice tutorial available here
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
have a look at www.connectionstrings.com
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thanks Bob for that response. That is a good site.
Please take a look at this code:
<Dim db as NEW ADO DB.Connection
Dim rs as NEW ADO DB.Record-set
DIM spath as String ' Path for the database
Dim SQLL as String ' Sql statement
sPath = app.path & "\DB\Name.mdb
>
Now the question is Bob: Is this code sufficient for connecting to an access DB? If not what is lacking?
Thank you!
|
|
|
|
|
i installled a window service that will access ftp server folder.
i get the following error The remote server returned an error: (500) Internal Server Error.. any idea pls
|
|
|
|
|
|
the article i found are on webservice. my application is window service. it actually execute the create folder before trowing the error
|
|
|
|
|
Your best bet to troubleshoot this issue is to mimic the steps that the windows service is doing.
Perform the same actions as the Service (login to FTP, read folders, etc) using a manual FTP client like FileZilla. Make sure you use the same login permissions, and are running the software from the same computer.
|
|
|
|
|
I'm developing a UserControl and I need to know when a user has changed the BorderStyle of the UserControl. I know that this is trapped in the UserControl's StyleChanged Event. But, I don't know how to determine which of the Control's Styles has changed and what it has changed to.
Does anyone have a code sample that would demonstrate this Event please.
Regards, Graham
|
|
|
|
|
Hi,
First Each n every control has its own style changed event if u still facing the problem in it then check the fous or active control in your form , One the control has focused=true n active means that control's border sytle has changed....
Hope this will help U
Unless u don't give ur hundred percent whatever u r doing till there is no result of ur work...
|
|
|
|
|
I think that I'm too simple to understand all of this.
Could you please translate this into something like English.
I can also speak French if that is easier for you.
Regards, Graham
|
|
|
|
|
Which thing is difficult to understand my english or the meaning of this what i said???
Which default control your are using to create a new user control????
There is 3 methods of doing this
1> Take default control eg textbox n add new features to create new textbox usercontrol
2>Use more than 1 control to create new user control
3>Create own user control without using any default
So which method you are using and which control???
May be i help u because i have also created user control before some time....
Unless u don't give ur hundred percent whatever u r doing till there is no result of ur work...
|
|
|
|