-
[RESOLVED] VB Crash course needed
Hello all.
I need some advice from you good people about a small project I have a little over 2 weeks to finish. Basically am creating a stock inventory system that is to be run on a hand held device, with a back end database created in Access and a simple front end created in VB.
The DB is created and it is now time to start assembling the front end, Unfortunately, on the VB ladder, i am still trying to get a foothold on the bottom rung. And I might be tempted to go as far as to say that a heavily diseased, severely retard gnat has more VB knowledge than myself.
What I am initially asking for help with is 2 things:
1) Should I create the front end as a Windows Application or a Device Application? Does it even make a difference?
2) The first thing I want to do is create the navigation within the application. I know code such as Me.Hide() Form2.Show() etc, but such commands are 'jittery' when executed, if you know what I mean. Is there any better code I can use?
Your help would be much appreciated. Ta.
-
Re: VB Crash course needed
If you are talking about a PDA or mobile device, you need to create the program as a project of the right type. After all, you will be using the .NET Compact Framework, which doesn't have all the same objects and methods that exist for desktop devices.
I also think that portables don't have Access anymore, but rather, use SQL Server CE, so when you state that the database is already created....is it? Is it installed and functional on the device? If so, what kind of device is it?
For mobile dev, I always favor the use of panels over forms. Loading forms takes noticeable time on a portable device. Instead, put all your controls on panels, move all the panels to a point off screen (set the top property to a value considerably larger than the display height), and then move them into the display area as needed. I wrote up a lengthier description of this, along with some examples, over in the mobile dev forum, but it was a couple years back. I might be able to find them if you can't and want to.
-
Re: VB Crash course needed
Cheers for the reply.
Yes, it is for use on a PDA.
Re the database, it's been created in Access and I thought I'd be able to bring it into the application. I have started a Device application project and it allows me to bring in the database via the server explorer, although i haven't actually accessed the db from within the application (that is to say I haven't recalled info or updated it yet - I'm simply not that far into creating the app yet in order to be able to test it).
I've never used panels before, are they easy to work with? I'll go and try and find your write up.
-
Re: VB Crash course needed
Panels are very easy to work with until you get too many of them. The advatages of them are that when you move the panel, all the controls on the panel move with them, and the panel can be swapped into and out of the display area instantaneously, while forms take time. Not a lot of time, mind you, but a second delay between forms is pretty noticeable.
I really thought an Access DB wouldn't even function on a PDA. There used to be a Pocket Access, but that was discontinued many years and many versions back. Perhaps it has been resurected. You will get SQL Server CE installed when you do any debugging on a PDA, and is probably preferable, but that usually requires a bit of a learning curve.
-
Re: VB Crash course needed
Hey,
I would have to go with Shaggy on this one, not sure you should be using Access on the PDA, SQL Server Compact Edition (which used to be known as SQL Server CE), that's not to say that you CAN'T use Access, but from what I have read, SQL Server Compact Edition is the way to go for Mobile Devices, as this opens up the possibility of Merge Replication with a full SQL Server Instance.
Panels are reasonably easy to work with, and they save the Mobile Device having to create and dispose of multiple forms, which is a time/resource consuming operation.
Gary
-
Re: VB Crash course needed
Thanks, I shall look into panels and see if I can handle them.
I have downloaded SQL Server Compact Edition and will have a look at it. The Db I have created is only basic, so it shouldn't take long to recreate it.
Back to an issue I raised in the opening post, and I'm sure this makes me seem like a moron, but should I be creating my app as a Device Application? I assume I should, but I would appreciate confirmation from people who know what they're talking about.
-
1 Attachment(s)
Re: VB Crash course needed
Quote:
Originally Posted by
WythyRed
Back to an issue I raised in the opening post, and I'm sure this makes me seem like a moron, but should I be creating my app as a Device Application? I assume I should, but I would appreciate confirmation from people who know what they're talking about.
Have you got the SDK's for Windows Mobile Installed? If so, you should see something like the following:
Attachment 70170
Hope that helps!!
Gary
-
Re: VB Crash course needed
I have:
- Smart Device
-------- Pocket PC 2003
-------- Smartphone 2003
-------- Windows CE 5.0
-
Re: VB Crash course needed
Hey,
Those are the ones that come with Visual Studio. You will need to download and install the others that are shown in my screenshot.
What version of Windows is on the device that you are specifically trying to target?
If it is Windows Mobile 5.0 or 6.1, then I would recommend that you download and install the SDK's that are for that version, that way you get the emulators that go with it and ensure you are targeting the correct version.
Gary
-
Re: VB Crash course needed
Ok, top man. I'll go off and download them.
-
Re: VB Crash course needed
I'm going to have to wait until tomorrow to find out what OS the PDA is running.
In the meantime, can someone explain to me how the panels would work? Do you just have multiple panels on one form, give them a location off the screen and then use buttons to bring each panel onto the screen as and when you need it, giving the illusion of different forms?
-
Re: VB Crash course needed
Thread moved from 'VB.Net' forum to 'Mobile Development' forum (thanks for letting us know gep13 :thumb: )
-
Re: VB Crash course needed
Yes, that's exactly it. I size all the panels to be full screen (there isn't much screen on a PDA, so use all of it), and design them willy-nilly on the form. I make the form itself as large as I possibly can for design purposes, as I end up needing to stach panels here and there once there get to be enough of them. I also have an integer on the form called TheState.
When the program starts, one of the first acts is to set the Left property of all panels to 0, and the Top property of all panels to something big, like 800. That is done in a sub (call it ClearAll), because it will be called often. There is then a sub called something like Ladder:
Code:
Public Sub Ladder()
ClearAll
Select Case TheState
Case 0
panel0.Top = 0
Case 1
panel1.Top=0
End Select
End Sub
To show a particular panel, I just have to set TheState to the proper panel that I want to show, and call Ladder. Note that the first thing Ladder does is calls that sub that sets ALL the panels Top properties to 800, so whatever is currently being shown is moved out of view, then the next one is moved into view.
In some versions of this, I also added a call before the Top property is set that sets up the panel. This would mean adding a Panel0Setup call in Case0, and so forth. The awkward thing about panels is that, since they are all on one form, all those subs are stuffed into the same form. You really need to use Regions to organize the code, but even so, there are some advantages, in that all the panels are actually there and accessible, even if they are not visible. You don't usually have that with forms, which are all different objects.
-
Re: VB Crash course needed
Your help is much appreciated.
I have designed 2 panels so far; the one that will be displayed initially when the app is run (Name: MainPanel) and one that is the panel that should be displayed when the Button2 on MainPage is pressed (Name of 2nd panel: DBPanel1). At the moment both panels are located at 0, 0 and i am moving between them by sending one to the back to bring the other forward.
As i have already confessed, I am useless at VB and I'm not entirely down with all the lingo. I understand the theory of what you are suggesting, but am unsure as to where the code will be placed.
You said that the first thing that needs to happen when the app is run is that the Left property for all panels is set to 0 and the Top property to be set to a figure that will send all but the initial panel off the screen. However, doesn't your code set the Top property of them all to 0 rather than 800?
Code:
Public Sub Ladder()
ClearAll
Select Case TheState
Case 0
panel0.Top = 0
Case 1
panel1.Top=0
End Select
End Sub
As outlined above, on MainPanel I have a button (Name: Button2) that when selected should bring the other panel (DBPanel1) onto the screen. What code would need to go behind the button?
Please don't lose patience with me, I'm sure that once I get the hang of it I should be able to add more panels relatively easily.
Thanks.
-
Re: VB Crash course needed
Hey,
Have a look at this thread:
http://www.vbforums.com/showthread.p...ight=GPSTracka
I know it's long, but it covers the topic that you are speaking about, specifically this post:
http://www.vbforums.com/showpost.php...3&postcount=76
You can then download the application from CodePlex and see how it is done.
Hope that helps!!
Gary
-
Re: VB Crash course needed
I've just read it, and to be honest, it made my head hurt. I can see where you've used the panels and the effect it had, but I'm none the wiser as to how you implemented it. I've had a look at the source code, but again it just baffled me, and I couldn't find the bit that dealt with the panels.
When I send one of my panels to Top = 800, the emulator simply adds scroll bars so that the panel I don't want to be seen, can be seen.
-
Re: VB Crash course needed
Hey,
I am away to go into a meeting, but I will dig out the source code and try to provide an explanation in a short while.
Gary
-
Re: VB Crash course needed
Hey,
In the GPSTracka application there are really two functions that control the showing and hiding of the panels of the application, and these are as follows:
Code:
private void ShowPanel(Panel panel)
{
panel.Location = new Point(0, 0);
panel.Dock = DockStyle.Fill;
switch (panel.Name)
{
case "settingsPanel":
{
this.Menu = settingsPanelMenu;
break;
}
case "aboutPanel":
{
this.Menu = aboutPanelMenu;
break;
}
case "mainPanel":
{
this.Menu = mainPanelMenu;
break;
}
default:
{
this.Menu = mainPanelMenu;
break;
}
}
}
Code:
private void HidePanel(Panel panel)
{
panel.Dock = DockStyle.None;
panel.Location = new Point(800, 800);
}
In fairness, these functions are written in C#, but the concept is the same.
When hiding the panel, change the docking of the panel to none so that it no longer fills the whole screen and then move it to somewhere a long way off the screen, i.e. point 800 800.
When it comes to showing the panel, the panel is first moved to position 0, 0 and then sets the docking to fill so that it fills the whole screen.
In addition, the name of the panel is inspected to ensure that the correct Menu associated with the panel is shown.
This isn't exactly the same as what Shaggy has suggested, but the concept is the same.
When it comes to showing a particular panel, the code is called as such:
Code:
private void aboutMenuItem_Click(object sender, EventArgs e)
{
HidePanel(mainPanel);
HidePanel(settingsPanel);
ShowPanel(aboutPanel);
}
In this case, the About button has been pushed, so we first make sure that the main panel and settings panel are hidden, then call show of the about panel. Given the small number of panels, this approach is fine, but if you have lots of panels, then this approach would have to be re-thought.
How many panels are you planning on having?
Hope the above makes sense!!!
Gary
-
Re: VB Crash course needed
Not sure if anything needs to be added after what Gep has posted, but perhaps there is a comment or two. In my post, ClearScreen would look like this:
Code:
Public Sub ClearScreen
panel0.Top = 800
panel1.Top = 800
End Sub
So it is that sub that would move all of the panels off the screen. Gep mentioned docking, which I didn't do, but which is probably safer these days with all the different screen resolutions.
However, you seem to have some confusion on how Select statements work. If that's the case, let us know, and we can explain them better.
-
Re: VB Crash course needed
Thanks, that's potentially the problem, i could end up with 6+ Panels on the same form.
-
Re: VB Crash course needed
Yeah, it probably doesn't help with me mixing languages as well, but to be honest I couldn't be bothered to convert it, I'm lazy :)
Gary
-
Re: VB Crash course needed
I'll have a bash with the above and see if i can crack it.
-
Re: VB Crash course needed
The select statement can be thought of an alternative for multiple if statements. Rather than going If this, Else this, Else this, you basically assert the condition. If this is the Case do this, Or if this is the Case, do this. You normally have a default Case as well to catch all the other Cases.
I think 6 Panels is still do-able with the method that I have suggested. Any more than say 10 would need to be re-thought.
Gary
-
Re: VB Crash course needed
Let me also add that if you use Gep's code converted over, note that C# requires that Break statement in every case block, while .NET should NOT have it.
-
Re: VB Crash course needed
Does the compact framework have LINQ? it would be easier to have a List of panels and use a LINQ to objects do da on the list to retrive each panel by name?
-
Re: VB Crash course needed
LINQ, LINQ, LINQ, that's all you guys ever talk about :):):)
I really need to start playing with that!! Haven't really had the chance said, as my work isn't up to 3.5 and I haven't had time to look at it personally.
To answer your question though, it is supported in the Compact Framework:
http://msdn.microsoft.com/en-us/library/bb397834.aspx
So maybe an example for the OP (and me) would be good.
Gary
-
Re: VB Crash course needed
ha ha, thats only because i have been testing out LINQ to xml and love it. im in work at the moment but I will certainly post an example when i get home (7pm GMT).
-
Re: VB Crash course needed
Sorry I got so much work on, from my limited knowledge here is a quick mock up, this would not be the best example but will give you an idea of how it works rather than many fors or ifs.
csharp Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Panel MainPanel = new Panel();
MainPanel.Name = "Main";
Panel MenuPanel = new Panel();
MainPanel.Name = "Menu";
Panel HappyPanel = new Panel();
MainPanel.Name = "Happy";
Panel SadPanel = new Panel();
MainPanel.Name = "Sad";
String ChoosePanelWithThisName = String.Empty;
List<Panel> ListOfPanels = new List<Panel>();
ListOfPanels.Add(MenuPanel);
ListOfPanels.Add(MenuPanel);
ListOfPanels.Add(HappyPanel);
ListOfPanels.Add(SadPanel);
IEnumerable<Panel> GetPanel = from PanelItem in ListOfPanels
where PanelItem.Name == ChoosePanelWithThisName
select PanelItem;
}
}
}
-
Re: VB Crash course needed
Sorry its long I just thought since the OP is using VB I wouldn't use code shortcuts so it will be easy for him to convert.
-
Re: VB Crash course needed
Thanks for your help thus far. I decided to go with the forms in the end, purely because i needed to get on due to time constraints, although in my write up i will say if i more time i would have looked into using panels rather than forms to increase the speed of the system.
Earlier on, some of you said that i would not/ might not be able to use an access database, can you tell me what software/program i need to design the db on so that is can be brought into the PDA based inventory system?
Thanks.
-
Re: VB Crash course needed
Hey,
If you go down the route of using SQL Server Compact, then you can do everything that you need to do, in terms of creating the tables and columns etc within Visual Studio itself.
Gary
-
Re: VB Crash course needed
Is that by using 'datagrid' on a separate form?
-
Re: VB Crash course needed
Hey,
I am not sure what you mean?!?
I thought you were talking about administering the database, i.e. creating tables, columns, relationships, etc all of this can be done with Visual Studio.
When it comes to actually getting the data from the Database, you are going to need to create a connection to the database, execute the queries that you want, and then populating the controls on the form with the data that you want.
Not all of the controls that you may be used to from a Desktop environment are available in the Compact Framework, so you sometimes have to be careful, depending on what you are doing.
Gary
-
Re: VB Crash course needed
Quote:
Originally Posted by
gep13
I thought you were talking about administering the database, i.e. creating tables, columns, relationships, etc all of this can be done with Visual Studio.
Yeah that's what i mean. I'm going to replicate the tables i had in the access db in visual studio, i just cant see where abouts in vb the create database option/feature is, if you get me.
-
Re: VB Crash course needed
Hey,
Ok, so we are on the same page :)
So what you need to do is as follows:
1) Open up Server Explorer
2) Click on the button to "Connect to Database"
3) In the window that opens up click on "Change"
4) Select "Microsoft SQL Server 2005 Compact Edition" (or whichever version you have installed) then click OK.
5) Click the create button, and enter the name for the new *.sdf file, and apply a password if you want one. Click ok
6) Hit the Test Connection button to make sure everything is ok, if it is, hit ok
7) Then in the Server Explorer, right click on the database, and then select Create Table
And that is you off and running.
Hope that makes sense!!
Gary
-
Re: VB Crash course needed
-
Re: VB Crash course needed
-
Re: VB Crash course needed
Last question i think: How do i manage the relationships between the tables? I cant see a relationships tab anywhere.
-
Re: VB Crash course needed
Hey,
Are you using Visual Studio 2008?
If so, you should be able to right click on the table that want to create a relationship for and select Table Properties.
In the window that opens up, click on Add Relations.
If you are using an earlier version of Visual Studio, then you will need to run a command similar to this:
Code:
ALTER TABLE Orders ADD FK_Customer_Order FOREIGN KEY (CustomerId)
REFERENCES Customers(CustomerId)
Hope that helps!!
Gary
-
Re: VB Crash course needed
I'm back, and looking for a couple of pointers if possible.
I'm trying to create a DB within Visual Studio. The following picture is one of the tables in my DB, and i need to know 3 things:
1) What is the equivalent data type of Accesses 'auto-number' in VB.net?
2) How can i make 'Location_ID' the key field as i cant see to find that option?
3) Do i have to define relationships between tables when i create sql queries?
http://www.vbforums.com/
The other aspect i need help with is how to go about displaying results when a user queries the DB.
I have a form in which the user enters the name of an object they want to search for, and then i need to display the location(s) of all those objects. Do i need another form to display the results (i've abandoned the panels stuff)? What type of control do i use from the toolbox to display the search results (Data Grid?)?
This is a screen shot of the form the user uses to input the name of the object they want to search for - as you can see it's basic:
http://img154.imageshack.us/img154/5...ectname.th.jpg
Thanks very much for your help.
-
Re: VB Crash course needed
Hi,
1) And identity field is the SqlServer equivalent of an autonumber field.
2) Click on the 'Key' icon to make it a primary key, or use the 'indexes' under the table in the treeview
3) Ideally yes
You can bind grids, listviews etc to your datasource, and do it that way, or retrieve the data into a sqlceresultset (recommended) or a dataset (slower) and populate textboxes/labels etc
-
Re: VB Crash course needed
1. Your database is not a VB.Net database, it is an SQL Server Express database - VB.Net just gives you a method to interact with it (alternatively you can download Management Studio Express from microsoft.com, which I think has more features).
The equivalent of AutoNumber is any numeric data type (such as Integer) with the Identity properties set.
I don't know how you would set them in VB.Net, as I haven't got VB.Net installed at the moment, and your picture doesn't seem to have the option - you may need to use Management Studio.
2. I suspect you just select the field then click the "key" icon on the toolbar.
3. Yes, and that applies no matter what kind of database you are using. It would generally be something like this:
Code:
SELECT Object.Field1, Location.Location_Name, AnotherTable.FieldA, ...
FROM Object
INNER JOIN Location ON (Object.Location_ID = Location.Location_ID)
INNER JOIN AnotherTable ON (Object.OtherID = AnotherTable.OtherID)
WHERE ...
By the way, it is best to avoid non alphanumeric characters (such as _ and space) in the names of tables and fields - they tend to cause problems.
In terms of display, I suspect a DataGrid is the best idea, but others may know better.
-
Re: VB Crash course needed
Hey,
3. Did you see my post in post #39, this explains how you can set up relationships between your tables.
With regard to the display of information, it comes down to what exactly you are trying to display. If you are displaying one record from a query, then it might be best to bind the fields to individual controls, i.e. Labels and TextBoxes, or if you are trying to display lots of results, then either bind to a DataGrid, or as pete suggested, you are add entries to a ListView or a TreeView, depending on again what kind of information you are trying to display.
Gary
-
Re: VB Crash course needed
Ta muchly. I've sorted the identifier and key field problems after your advice.
All I'm trying to do is allow the user to select an object from a combo box (or, on another form, a location) and then display info on that object - Ie select modem from the combo box and then have the system display information (location, etc) about those objects.
However, when i try and navigate to the form where the combo is i'm currently getting an error and the page wont load. This is the piece of code it's highlighting:
Code:
Me._connection.ConnectionString = "Data Source=EXPERIEN-665F4D\SQLEXPRESS;Initial Catalog=""Project DB"";Integrated Se"& _
"curity=True;Pooling=False"
Any ideas?
-
Re: VB Crash course needed
Hi,
connection string looks a bit 'iffy' - unneeded quotes around the catalog.
This is a valid connection string, although, you may need to use the ip address.
Persist Security Info=False;Integrated Security=False;Server=Till1\SqlExpress;initial catalog=mybase;user id=sa;password=mypass;
Pete
-
Re: VB Crash course needed
Quote:
Originally Posted by
WythyRed
Code:
Me._connection.ConnectionString = "Data Source=EXPERIEN-665F4D\SQLEXPRESS;Initial Catalog=""Project DB"";Integrated Se"& _
"curity=True;Pooling=False"
Any ideas?
U have to use IP like
"Datasource = 192.168.1.10\SQLExpress;initial catalog=NameDataBase;user id=sa;password=password;"
or resolve name to IP address.
-
Re: VB Crash course needed
OK, I'm back on this project. I had hoped to have it done by now, but no matter. I just want to get it done asap.
I've got a sqlExpress DB within my project (which is now in VS 2008) and I'm trying to create get a combo box to work that displays a list of locations taken from the database:
http://img413.imageshack.us/img413/710/combo.th.jpg
However, when I try to run the emulator i get the following error message:
'Setup Error
.NET Compact Framework v2.0 could not be found. Please install it and run this setup again.'
Now, I currently have .NET Compact Framework v2.0 installed (I can see it in add/remove programs) .NET Compact Framework v3.5 installed. When i tried to remove v3.5 my project wouldn't open as it uses it.
Does anyone have any ideas? I would have thought that v3.5 would have been backwards compatible.
-
Re: VB Crash course needed
Hey,
Can you confirm where exactly that error message is being displayed? Is it on the Emulator, or within Visual Studio?
Gary
-
Re: VB Crash course needed
It's when I try and run the emulator.
The picture of the PDA appears, and within that comes that error message. I can't seem to take a screen shot of it though.
-
Re: VB Crash course needed
Hey,
This would suggest that the .Net Compact Framework 2.0 is not installed on the Emulator that you are starting up. And it is needed by the application you are trying to run.
Which emulator are you starting?
Gary
-
Re: VB Crash course needed
I only have the choice of 3, and have been trying to use the highlighted one - USA Windows mobile 5 Pocket PC R2 Emulator.
http://img216.imageshack.us/img216/7344/emulator.th.jpg
-
Re: VB Crash course needed
Hey,
I have just done a bit of googling on the subject, and I think these knowledge base articles might help you out...
http://support.microsoft.com/kb/945316
http://support.microsoft.com/kb/945371
Gary
-
Re: VB Crash course needed
I've uninstalled 2005 and that's allowed me to run the emulator - thanks.
Now i've just got to get around the compile errors!
-
Re: VB Crash course needed
I'm now getting the following error when I try and navigate to the page where the combo box is:
"Can't find PInvoke DLL 'dbnetlib.dll'"
I've done a google search and found the following:
http://social.msdn.microsoft.com/For...6-6104de8b9480
"Copy the required cab file to the emulator file system, and click it in File Manager (in the Emulator).
You can use the Remote Tools (Remote File Viewer), or you can cradle the device. Look fro example here:
http://windowsmobilepro.blogspot.com/2006/04/emulator-troubleshootingtip-01-to.html"
Does anyone know how to do that? I've tried but got no where.
-
Re: VB Crash course needed
Hi,
are you using SQL Client, and have you installed it to the device? The article tells you about installing the cab file.
-
Re: VB Crash course needed
To be honest, I have no idea if I'm using that or not, and I haven't installed anything to the emulator/device.
-
Re: VB Crash course needed
I've copied the files to the emulator using remote files.
http://img19.imageshack.us/img19/882...eviewer.th.jpg
Still getting the error message though.
-
Re: VB Crash course needed
This is just a stab in the dark but do you not need to execute the CAB file as well?
Gary
-
Re: VB Crash course needed
When you double click it on the remote file viewer it just brings up details about the file and doesnt allow you to execute it.
-
Re: VB Crash course needed
Hey,
Go into the Emulator and browse to the CAB file using File Explorer and click on it from there. You cannot execute the CAB file from the remote file viewer, you need to do it on the Emulator itself.
Gary