|
I solved the problem by using
Me.ToolStripMenuItem1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {....})
in the Opening event of each menu strip.
That way I don't have to handle the events of the items separately and a single code works for both.
But I still don't understand why the first code didn't work, I even created a new list of the items and populated the list with "New" instance of the items but adding the list to the new menu would remove them from the original one .
Thanks anyway
|
|
|
|
|
All UI controls can only haev one parent container. You tried to have the same control have two parent containers. Doesn't work that way.
|
|
|
|
|
This code, to open and read a local access 2007 database, works perfectly fine on my (Vista) development station:
<br />
'open the Access 2007 database without a password<br />
Dim DBconnection As OleDbConnection<br />
Dim DBcommand As OleDbCommand<br />
Dim DBdataReader As OleDbDataReader = Nothing<br />
Dim strProgramPath As String = System.AppDomain.CurrentDomain.BaseDirectory()<br />
Dim strDBfullPath As String = strProgramPath + "labs.accdb"<br />
DBconnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + strDBfullPath + ";Persist Security Info=False;")<br />
DBconnection.Open()
However, once I copy my program to the Windows Server 2008 machine as well as the same database I used for development: 1) the code above takes a long time to execute 2) .Open fails
Why does it work fine on Vista, but fails on Server 2008 eventough the database on both machines are the same ?
|
|
|
|
|
so the problem here seemed to exist because the compilation was set to "any CPU".
Once I set the compilation option to x86, the application was able to open the database on the Server 2008 machine too (64bit machine).
So it seems there's no 64bit driver to access an Access 2007 DB ?
I'm glad it's at least working now, however, on my (32bit) Vista development station the data access is very fast and on the (64bit) Server 2008 station data access is very slow; instant vs. 30 secs
|
|
|
|
|
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
abiemann wrote: So it seems there's no 64bit driver to access an Access 2007 DB ?
True, at this time there is no 64-bit drivers for a Jet database (Access). Since you cannot mix 64 and 32 bit code in the same process, you have no choice but to compile your app forced down to 32-bit only. If you used any of the SQL Servers, including SQL Server Express Edition, you wouldn't have this problem.
|
|
|
|
|
I wish to create a property which has sub properties (sorry if this is the wrong wording) similar to the Size property each control already implements..
Control.Size returns System.Drawing.Size
whereas you can still access
Control.Size.Width returns an Integer
I suppose sub property would be the best word to describe the 'Width' property
Any ideas how to implement this hierarchy of properties on your own custom properties?
|
|
|
|
|
You need to apply a TypeConverter attribute, specifying either an ExpandableObjectConverter, or one derived from it.
Using PropertyGrid Part-I[^] has an example (and googling might find others that more directly address this), search for ExpandableObjectConverter for the relevant bit.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Not sure what problem are you facing. Nested properties (not sure this wording also correct) are trivial to implement. Here is a C# implementation as my VB is poor.
class Employee
{
Address homeAddress =
public Address HomeAddress
{
get
{
return homeAddress;
}
}
}
class Address
{
string street;
public string Street
{
get
{
return street;
}
}
string city;
public string City
{
get
{
return city;
}
}
} Now you can write,
Employee chuckNorris = new Employee();
chuckNorris.HomeAddress.Street = "Set the street here";
chuckNorris.HomeAddress.City = "set the city here";
|
|
|
|
|
This, I all understand.
My problem lies specifically within the Size property, as I'm trying to overload it, along with the properties that the Size property has (specifically height and width).
|
|
|
|
|
So you need to expose a property that has all the properties of Size available and your own custom properties. Is that right? If yes, you need to create a completely new type. Also I just noticed that Size is a structure and you will get a compiler error if you write
control.Size.Width = some value
If you are creating new type, I would consider a class over a struct.
|
|
|
|
|
Thanks I'll look into that, but out of curiousity are you saying that if I have a button, I cannot do..
button1.Size.Width = 60
I must have misunderstood your post, I think I'm going to tackle this another way..
|
|
|
|
|
Since struct is a value type, button1.Size returns a copy of original size. Changing a property value on it won't affect the original size instance which is in the control. So you need to do
button1.Size = new Size(width, height)
Hope that is clear
|
|
|
|
|
... or button1.Width=width;
|
|
|
|
|
My memory seems to be fading away from me here, you are both correct. My mistake.
|
|
|
|
|
How to . Which data provider can use to implement that.
|
|
|
|
|
Something like this[^]? I got it by Googling "MySQL data provider .net"
Amazing hits that come from that Google machine..
|
|
|
|
|
|
I am using vb express and MsAccess as database.
I am trying to write a query for the calculation of Stock.
My tables are as under:
Data in PurchaseTable
PId PDate ItemId Description Price Quantity Amount
1 28/8/2009 1 Coca Cola Normal 1,00 10 10,00
2 28/8/2009 2 Coca Cola Zero 1,00 5 5,00
3 29/8/2009 1 Coca Cola Normal 1,00 5 5,00
4 29/8/2009 2 Coca Cola Zero 1,00 10 10,00
Data in Sales Table is as under:
SId SDate ItemId Description Price Quantity Amount
1 30/8/2009 1 Coca Cola Normal 2,70 2 5,40
2 30/8/2009 2 Coca Cola Zero 2,70 3 7,10
3 31/8/2009 1 Coca Cola Normal 2,70 1 2,70
4 31/8/2009 2 Coca Cola Zero 2,70 2 2,70
I want a query for stockcalculation to show data as under:
PDate,ItemId, QuantityPurchased, QuantitySold, Balance(QuantityPurchased - QuantitySold)
Please advise how I can get the above information through a query on the above two tables to be displayed in a Listview.
|
|
|
|
|
You are in the wrong forum, but try this link: http://www.w3schools.com/sql/default.asp[^]
There you will find a free tutorial that will teach you how to do this.
My advice is free, and you may get what you paid for.
|
|
|
|
|
General Database would have been a better forum.
sazd1 wrote: I want a query for stockcalculation
What have you tried?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
thanks for your reply I tried something like this:
Dim cmdText As String = "SELECT pt.ItemId, pt.Description, SUM(pt.Quantity)AS QuantityPurchased, SUM(st.Quantity) AS QuantitySold, (SUM(pt.Quantity) - SUM(st.Quantity)) AS Balance FROM PurchaseTable pt INNER JOIN SalesTable st ON pt.ItemId=st.ItemId WHERE pt.PDate Between @START and @END GROUP BY pt.ItemId, pt.Description"
But it did not give the desired results. it is not making the correct calculations.
|
|
|
|
|
To do this you have to create another table with following fields for store remaining stock.
ItemID Description Price Quantity
When you make a transaction update the Stock table. When generating the listview ignore PDate field. You can get QuantityPurchased and QuantitySold fields from Purchase table and Sales table. You can get Balance field from Stock table
|
|
|
|
|
I tried something like this to have balance of stock at any date or interval between two dates
Dim cmdText As String = "SELECT pt.ItemId, pt.Description, SUM(pt.Quantity)AS QuantityPurchased, SUM(st.Quantity) AS QuantitySold, (SUM(pt.Quantity) - SUM(st.Quantity)) AS Balance FROM PurchaseTable pt INNER JOIN SalesTable st ON pt.ItemId=st.ItemId WHERE pt.PDate Between @START and @END GROUP BY pt.ItemId, pt.Description"
If con.State = ConnectionState.Closed Then con.Open()
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(cmdText, con)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("@START", OleDb.OleDbType.Date).Value = TextBox1.Text
cmd.Parameters.AddWithValue("@END", OleDb.OleDbType.Date).Value = TextBox2.Text
Dim dr As OleDb.OleDbDataReader
If con.State = ConnectionState.Closed Then con.Open()
dr = cmd.ExecuteReader
If Not dr.HasRows Then
MessageBox.Show("No Records Found for Date: " & TextBox1.Text)
Else
MessageBox.Show("Record found for Date: " & TextBox1.Text)
ListView1.Items.Clear()
ListView1.ForeColor = Color.DarkRed
ListView1.GridLines = True
While dr.Read
Dim ls As New ListViewItem(dr.Item("ItemId").ToString())
ls.SubItems.Add(dr.Item("Description").ToString())
ls.SubItems.Add(dr.Item("QuantityPurchased").ToStr ing())
ls.SubItems.Add(dr.Item("QuantitySold").ToString() )
ls.SubItems.Add(dr.Item("Balance").ToString())
ListView1.Items.Add(ls)
End While
End If
But i could not get the desired results. Please advise what i am doing wrong with this.
The problem i am having is as under:
Data in PurchaseTable
PId PDate ItemId Description Price Quantity Amount
1 28/8/2009 1 Coca Cola Normal 1,00 10 10,00
2 28/8/2009 2 Coca Cola Zero 1,00 5 5,00
3 29/8/2009 1 Coca Cola Normal 1,00 5 5,00
4 29/8/2009 2 Coca Cola Zero 1,00 10 10,00
Data in Sales Table is as under:
SId SDate ItemId Description Price Quantity Amount
1 30/8/2009 1 Coca Cola Normal 2,70 2 5,40
2 30/8/2009 2 Coca Cola Zero 2,70 3 7,10
3 31/8/2009 1 Coca Cola Normal 2,70 1 2,70
4 31/8/2009 2 Coca Cola Zero 2,70 2 2,70
The result of query with date range of 28-08-2009 to 29-08-2009 and also with the date range of 28-08-2009 to 31-08-2009 is displayed as under:
Coca Cola Normal 30 6 24
Coca Cola Zero 30 10 20
whereas actually for date range of 28-08-2009 to 29-08-2009 the result should be as under:
Coca Cola Normal 15 0 15
Coca Cola Zero 15 0 15
And with the date range of 28-08-2009 to 31-08-2009 the result should be as under:
Coca Cola Normal 15 3 12
Coca Cola Zero 15 5 10
Pleae advise what i am doing wrong with the query.
Thanks again for your guidance.
|
|
|
|
|
Hello Everyone
I need some help i have been googleing this all night i think it is pretty simple to do just cant find any info
all i am trying to do is
have a button click on a set time
example
have my button1 click at 5:34 PM every day
how can i do that ??
Thanks in advance
Bob
|
|
|
|