|
The folowing is a Table and it's data of an MS Access Database
Table: EXPENSES
EDATE(Date) ETYPE(String) AMOUNT(Currency)
---------------------------------------------
01/01/07 Electricty 1000
21/01/07 Phone 1500
24/01/07 Repair 2000
05/02/07 Electricty 1000
23/02/07 Phone 1500
---------------------------------------------
Controls used on the VB form are...
-------------------------------------
Data Control named Data1
DBGrid named db1, It's Data source set to Data1
DatePickers named DTPicker1 and DTPicker2
Command Button named CmdExp
Running the code
----------------
DatePicker1 set to 01/01/07 and DatePicker2 set to 21/03/07
Following is the code executed when CmdExp is Clicked...
--------------------------------------------------------------
Private Sub CmdExp_Click()
Dim rs_exp As Recordset
Set rs_exp = db.OpenRecordset("select * from EXPENSES where EDATE >= " & DTPicker1.Value & " and EDATE <=" & DTPicker2.Value & " ")
Set Data1.Recordset = rs_exp
End Sub
The OutPut is
-------------
01/01/07 Electricty 1000
21/01/07 Phone 1500
05/02/07 Electricty 1000
Why does the two records with date 24/01/07 and 23/02/07 is not displayed even though they are between the two date ranges ?
|
|
|
|
|
IF the output is comming like what you have shown then try saving the databas table bafre running the progam and also close the table and then check tha out put. See if it works .
|
|
|
|
|
first, it is much better to use "between" instead of the greater than and equal...
second, maybe because of a time issue
make your two dates boundless to time... format it and parse it as date.
|
|
|
|
|
Maybe this is the wrong place to ask this question but...
I read a lot of posts on other message boards dis-sing Visual Studio 2005 and in particular VB .NET.
I started using VB .NET because I wanted a platform to create exe's and potentially make money out of writing applications.
As an experienced developer in Access and VBA as well as being a SQLServer DBA I wonder if I have made the correct choice with VB .NET.
Now I know that most people posting on this board will probably praise VB .NET however I'd like to hear of others' experiences and how useful is VB .NET including what it's future holds, and examples of strong commercial applications that have been written in VB .NET.
I know I'm asking for a lot...
Guy
You always pass failure on the way to success.
|
|
|
|
|
GuyThiebaut wrote: Now I know that most people posting on this board will probably praise VB .NET
Don't count on it.
There's a large group of people out there who just love to hate VB because of it's rather rocky beginnings and lack of type safety and implicit conversion and ... and ... These are mostly people who come from a C/C++ background.
There's nothing wrong with learning VB.NET and the only problem I see is that your just sticking with VB alone. Don't. Learn as many languages as you can. C# compiles to just about the same MSIL code as VB.NET does. C# has it's roots in a multitude of languages, including VB, so learning C# should be pretty easy.
Also, there's things that VB.NET does that C# can't. The opposite is also true. VB.NET support optional parameters, where C# doesn't. Do some Office Interop in both languages and you'll soon learn to love VB for this ability! C# supports unsafe code and points where VB.NET doesn't. C# is much better for getting directly at the bytes for image manipulation.
Learn as much as you can, VB.NET, C#, Java, SQL, ... It's far more common to write apps in multiple languages than the nay-sayers would care to admit.
|
|
|
|
|
That sounds like good advice based on experience.
I did have a go at C(+) years ago but not being used to OOP it was too early.
On reading what you say I may have a look at C#.
Thanks for that Dave.
You always pass failure on the way to success.
|
|
|
|
|
GuyThiebaut wrote: may have a look at C#
That would be better.
GuyThiebaut wrote: not being used to OOP
OOP is pretty much the game now. I don't remember when I last did good old fashion top-down programming...
|
|
|
|
|
IMO, whichever language you prefer for .NET you should be able to read and understand the other. This is because you will often see useful examples written in only one or the other and you should be able to take advantage of them.
Kevin
|
|
|
|
|
GuyThiebaut wrote: and examples of strong commercial applications that have been written in VB .NET.
As VB.NET code is not secure ( your end users can read it ), a better question would be 'how many web sites use ASP.NET', and 'how many contractors use .NET to write code for specific end users' ?
Note I said '.NET' and not 'C#'. In truth, VB is a nasty little language, but if you understand it, your apps are going to do the same stuff a C# app can do, so there's no real reason to move to C#, if you're comfortable with VB syntax.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I just knew you were going to chime in on this one!
Christian Graus wrote: As VB.NET code is not secure ( your end users can read it ),
Bunch of crap! Of course it's secure, 'cause noone WANTS to read it! Once someone sees it, they say "This can't be a serious app worth my time..."
It's kind of like the great PC/Mac debate. One side thinks the other size sucks. To me, I still get paid by the hour, no matter which language I use.
|
|
|
|
|
In VB6, the underscore is always visible for the hot-key when you use an & in a label. In dotnet, you need to press the alt-key to see the underscore. Any way to override that so the underscore is always visible?
|
|
|
|
|
No. This is a system setting that has nothing to do with your code.
RIght-click the Desktop and pick Properties. Depending on which version of Windows you have, click on the Effects tab (2000) or Appearance tab (WinXP). If XP, click on the Effects button. You're looking for something like "Hide underlined letters for keyboard navigation until I press the Alt key."
No, you can't override it in your app.
|
|
|
|
|
|
Hi,
I'm trying to update the values in a DataGridView. It works ok, and I can see my rows and columns being updated, but when I scroll down the grid, and hit the bottom, it throws an "object not set to an instance of an object" error - and the space occupied by the grid changes to a red cross.
I'm obviously doing something wrong, and have narrowed the problem down to this bit of code:
Dim gridrow As DataRowView<br />
<br />
Dim intItemFoundOnRow As Integer = bindingDataGridView2.Find("File Name", strSearch)<br />
<br />
If intItemFoundOnRow <> -1 Then<br />
<br />
gridrow = bindingDataGridView2.Item(intItemFoundOnRow)<br />
<br />
gridrow.BeginEdit()<br />
<br />
gridrow.Item("Columns in Database") = CountColumnsInTable(strTableName)<br />
<br />
gridrow.EndEdit()<br />
<br />
End If
It isn't anything to do with the CountColumnsInTable function, because I can replace this line with:
gridrow.Item("Columns in Database") = 9999
... and it makes no difference. I threw in .BeginEdit and .EndEdit in an attempt to get it to work, but these lines may as well not be there.
|
|
|
|
|
Just an idea - is there any chance that you are trying to read past the end of the object bound to the datagrid.
In some cases the first record in an object is 1 and in some cases it is 0 (I can't remember what is is in the case of a datagrid)
I could be way off track here.
You always pass failure on the way to success.
|
|
|
|
|
Thanks for your thoughts.
I managed to fix it. The problem was that I had created a sorted DataView, and populated the DataGridView with it - which had the effect of sorting one of the columns, which seemed to have messed up the indexing.
One thing I can't get my head around is that the grid was bound to the dataview, so the indices should, I think, have worked - irrespective of the sort.
|
|
|
|
|
Hi everyone, Pls. am trying to create a dataset component using generate dataset wizard, but my (vb.net sdk v1.1) does not have the wizard, how can i use the Dataset component by draging it on the windows form???
If you can't do big things, then do small things in big ways...
|
|
|
|
|
Are you still having trouble with this? What IDE are you using?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Sorry you did not quite answer my question.. i was trying to ask how to access an 'Access Database' thru a windows form created on VB.NET .
If you can't do big things, then do small things in big ways...
|
|
|
|
|
You did not mention what database you were using in your original post. Access databases are not really different than any other database.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello all -
this might be a basic question but I can't seem to get the answer right. I have a byte array which needs to be converted to specific data types. I am using the BitConverter class for the conventional conversion such as Int16, Int32 etc. Some of the parameters in the array cannot be converted directly to the specific integer types using the BitCOnverter methods. For example -
parameter1 is the first 3 bytes in the array and needs to be Uint32 for decoding purposes. If I use the convert to Uint32 method - it automatically takes the first 4 bytes. Is there a way to convert just those 3 bytes.
same is true for the next parameter which is only 1 byte but again needs to be Uint32.
Thanks a million
|
|
|
|
|
captainmogo wrote: parameter1 is the first 3 bytes in the array and needs to be Uint32 for decoding purposes. If I use the convert to Uint32 method - it automatically takes the first 4 bytes. Is there a way to convert just those 3 bytes.
I'm not sure if the BitConverter has anything for this. But a solution that would work is to create an array of 4 bytes, copy the 3 bytes in (ensure the remaining byte is zero) and convert it. I think the byte that has to be zero is the last one, but you might want to check that - its been a while since I've done anything at that level.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Adding to Colin's reply:
On "little=endian" systems (such as all Intel/Intel-compatibles) the first byte has the
lowest weight (so you want to clear the fourth byte).
On "big-endian" systems (such as PowerPC, VAX, and then some) it is the opposite.
That's for the representation in memory; what you do in a file is up to you (most systems
use their memory convention, making file exchange difficult between LE/BE systems).
On a wire (such as Ethernet) there are fixed conventions; Ethernet is big-endian.
If you want to write code that supports both, I guess there is a methor or property somewhere,
that tells you what endianness your system has; but I would tend to just test it once at
run-time.
BTW there are two completely different approaches to your conversion problems:
1. write the formulas; looks like threeByteInt=(((byte2<<8)|byte1)<<8)|byte0);
2. use a struct with Marshaling attributes and explicit FieldOffset to simulate
real unions (ala C/C++) or commons (ala Fortran).
|
|
|
|
|
I have copied code from another project where the very same thing works perfectly but in this particular case it just moves right past the call. The only difference between the class I used before and the one I use it in now is that the current class implements IDisposable .
Class 1 (Calling class) values
Private WithEvents _ObjectName As Object
Private Sub UpdateStatus(ByVal sender As Object, ByVal e As System.EventArgs) Handles _ObjectName.StatusChanged
'Code to run here
End Sub Class 2 (Called class) values
Public Event StatusChanged As EventHandler
Public Property CurrentStatus() As Integer
Get
Return _Status
End Get
Set(ByVal value As Integer)
_Status = value
RaiseEvent StatusChanged(Me, EventArgs.Empty)
End Set
End Property
Maybe a fresh set of eyes will see something that I dont.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Private WithEvents _ObjectName As Object<br />
<br />
Private Sub UpdateStatus(ByVal sender As Object, ByVal e As System.EventArgs) Handles _ObjectName.StatusChanged
i don't think that the Object class has StatusChanged event
|
|
|
|