Page 2 of 5 FirstFirst 12345 LastLast
Results 41 to 80 of 162

Thread: [RESOLVED] VB Crash course needed

  1. #41
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    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
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  2. #42
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  3. #43
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  4. #44

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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?

  5. #45
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    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.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  6. #46
    Lively Member
    Join Date
    Oct 2008
    Posts
    81

    Re: VB Crash course needed

    Quote Originally Posted by WythyRed View Post
    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

  7. #47

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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.

  8. #48
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  9. #49

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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.

  10. #50
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  11. #51

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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.


  12. #52
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  13. #53

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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!

  14. #54

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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.

  15. #55
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    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.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  16. #56

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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.

  17. #57

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    Re: VB Crash course needed

    I've copied the files to the emulator using remote files.



    Still getting the error message though.

  18. #58
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  19. #59

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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.

  20. #60
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  21. #61

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    Re: VB Crash course needed

    Yeah, just realised that after I posted. I've executed them but still got the error:


  22. #62
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  23. #63

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    Re: VB Crash course needed

    Yeah, I saved the state.

  24. #64

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    Re: VB Crash course needed

    This is the line of code the error points to:

    Code:
    Dim returnValue As Integer = Me.Adapter.Fill(dataTable)

  25. #65
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  26. #66

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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?

  27. #67

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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;"

  28. #68
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  29. #69

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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.

  30. #70
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  31. #71

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    Re: VB Crash course needed

    Top man, I'll try it when I get in from work.

  32. #72

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    Re: VB Crash course needed

    Do i create a .sdf file through Microsoft SQL server 2005 - SQL server management studio express?

  33. #73
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    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
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  34. #74

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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.

  35. #75
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: VB Crash course needed

    You can insert them using queries in the management studio
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  36. #76

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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)

  37. #77
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    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
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  38. #78
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: VB Crash course needed

    Also, have a look here:

    http://www.w3schools.com/sql/default.asp

    That will give you the basics.

    Gary

  39. #79

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    82

    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?

  40. #80
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: VB Crash course needed

    Nope - not supported.

    What appears to be the problem(s)?
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

Page 2 of 5 FirstFirst 12345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width