|
-
May 1st, 2009, 10:46 AM
#41
Frenzied Member
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
-
May 1st, 2009, 11:34 AM
#42
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.
-
May 2nd, 2009, 03:24 AM
#43
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
-
May 3rd, 2009, 03:59 PM
#44
Thread Starter
Lively Member
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?
-
May 4th, 2009, 01:42 AM
#45
Frenzied Member
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
Last edited by petevick; May 4th, 2009 at 05:26 AM.
-
May 4th, 2009, 01:42 AM
#46
Lively Member
Re: VB Crash course needed
 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.
Last edited by masteripper; May 4th, 2009 at 01:48 AM.
Reason: Add more info
-
Jun 9th, 2009, 10:48 AM
#47
Thread Starter
Lively Member
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:

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.
-
Jun 9th, 2009, 10:51 AM
#48
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
-
Jun 9th, 2009, 11:13 AM
#49
Thread Starter
Lively Member
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.
-
Jun 9th, 2009, 11:15 AM
#50
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
-
Jun 9th, 2009, 11:19 AM
#51
Thread Starter
Lively Member
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.
-
Jun 9th, 2009, 11:25 AM
#52
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
-
Jun 9th, 2009, 11:45 AM
#53
Thread Starter
Lively Member
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!
-
Jun 9th, 2009, 02:16 PM
#54
Thread Starter
Lively Member
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.
-
Jun 10th, 2009, 01:31 AM
#55
Frenzied Member
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.
-
Jun 10th, 2009, 04:11 AM
#56
Thread Starter
Lively Member
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.
-
Jun 10th, 2009, 05:58 AM
#57
Thread Starter
Lively Member
Re: VB Crash course needed
I've copied the files to the emulator using remote files.

Still getting the error message though.
-
Jun 10th, 2009, 06:28 AM
#58
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
-
Jun 10th, 2009, 06:36 AM
#59
Thread Starter
Lively Member
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.
-
Jun 10th, 2009, 06:38 AM
#60
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
-
Jun 10th, 2009, 06:42 AM
#61
Thread Starter
Lively Member
Re: VB Crash course needed
Yeah, just realised that after I posted. I've executed them but still got the error:
-
Jun 10th, 2009, 06:48 AM
#62
Re: VB Crash course needed
Hey,
When you executed the CAB file, did you save the state of the emulator? Or when you ran the application again, do you create a new instance of the emulator? If you did the latter, then this is why you are still getting the error. You need to execute the CAB file, and then save the state, so that it remembers that it has it installed.
Gary
-
Jun 10th, 2009, 06:53 AM
#63
Thread Starter
Lively Member
Re: VB Crash course needed
-
Jun 15th, 2009, 03:58 AM
#64
Thread Starter
Lively Member
Re: VB Crash course needed
This is the line of code the error points to:
Code:
Dim returnValue As Integer = Me.Adapter.Fill(dataTable)
-
Jun 16th, 2009, 01:55 AM
#65
Re: VB Crash course needed
Hey,
Given that the line that is causing the error is to do with connection to the Database on the device then it is a good bet that this is the route of the problem.
Can you verify that you have installed the correct version of the SQL Client. Also, have you copied the database to the device? Is it stored in the same location? If not, have you changed the connection string to reflect this?
Gary
-
Jun 16th, 2009, 05:24 AM
#66
Thread Starter
Lively Member
Re: VB Crash course needed
I've created an sql Db within VS 2008, I've not transferred the database to the device as I thought that when you try and run the program in VS 2008 through the emulator it would send the database with it. Is that not the case?
-
Jun 16th, 2009, 05:28 AM
#67
Thread Starter
Lively Member
Re: VB Crash course needed
This is from the code:
Code:
Me._connection.ConnectionString = "Data Source=EXPERIEN-665F4D\SQLEXPRESS;Initial Catalog=Project;Integrated Securit"&"y=True;"
-
Jun 16th, 2009, 05:49 AM
#68
Re: VB Crash course needed
Hey,
Hold on now, are you saying that you have created an SQL Express Database? If that is the case, then this will not create a database on the device for you, quite simply, it can't!! SQL Express is a Desktop Database system, not for a Mobile Device.
If you are actually wanting the database to be local to the device, then you are going to have to create an SQL Server Compact Database, an sdf file, and copy that onto the device.
What I suspect is happening is that the emulator is trying to connect to the database on the host PC, and it isn't able to.
Can you explain exactly what you are trying to achieve.
Gary
-
Jun 16th, 2009, 06:32 AM
#69
Thread Starter
Lively Member
Re: VB Crash course needed
I'm trying to create a basic stock control system.
There's a db that needs to be on the device that has a table of locations and a table of objects. I need the user to be able to search for an object to discover its location (which i tried to do via a combo box - where the user could select the object from a drop down list), and, on a separate form, search for a list of objects in a particular location, again using a combo box.
To create the db in VS 2008 i have gone on data connections on the right hand side, right clicked and selected 'Create new SQL server database' and then created the tables within that.
-
Jun 16th, 2009, 06:43 AM
#70
Re: VB Crash course needed
Hey,
In which case, this sounds like you want a database which is located solely on the device, and therefore you do not want to create a SQL Server Database (which creates an MDF file) but rather a SQL Server Compact Edition Database (which creates an SDF file). Once you have done this, you will be able to include this database in the package that gets deployed to the device and it will run locally on the device.
Gary
-
Jun 16th, 2009, 07:21 AM
#71
Thread Starter
Lively Member
Re: VB Crash course needed
Top man, I'll try it when I get in from work.
-
Jun 19th, 2009, 04:29 AM
#72
Thread Starter
Lively Member
Re: VB Crash course needed
Do i create a .sdf file through Microsoft SQL server 2005 - SQL server management studio express?
-
Jun 19th, 2009, 06:57 AM
#73
Frenzied Member
Re: VB Crash course needed
In Sql2005 Management Studio...
Click on 'Connect'>SQL Server Compact Edition
In the Database File combo, drop down the list and select 'New Database'
HTH
-
Jun 20th, 2009, 10:47 AM
#74
Thread Starter
Lively Member
Re: VB Crash course needed
Yeah that helps greatly, now, to make myself look even more clueless, how do I enter records into the DB? Is that through the management studio too or must it be done through my application?
Thanks for the help as always.
-
Jun 20th, 2009, 11:56 AM
#75
Frenzied Member
Re: VB Crash course needed
You can insert them using queries in the management studio
-
Jun 20th, 2009, 01:48 PM
#76
Thread Starter
Lively Member
Re: VB Crash course needed
Ta.
I've never added data using a query before is there a standard query you'd use? I've had a look online but been unable to find anything.
I have the following tables to which i need to add data:
ObjectTable (ObjectID, ObjectName, LocationName, Object, Detail1, Detail2, Detail3, Detail4, Detail5)
LocationTable (LocationID, LocationName, Picture)
-
Jun 21st, 2009, 02:34 AM
#77
Frenzied Member
Re: VB Crash course needed
Look for Insert in the SQL help file - it will show you all the syntax and show you examples.
Insert into objecttable values (1,'Name','Location','Object'...) etc
-
Jun 22nd, 2009, 02:44 AM
#78
Re: VB Crash course needed
Also, have a look here:
http://www.w3schools.com/sql/default.asp
That will give you the basics.
Gary
-
Jun 23rd, 2009, 03:19 PM
#79
Thread Starter
Lively Member
Re: VB Crash course needed
I'm having murders using the SQL CE, is there no way i can use access on a mobile device?
-
Jun 23rd, 2009, 03:34 PM
#80
Frenzied Member
Re: VB Crash course needed
Nope - not supported.
What appears to be the problem(s)?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|