Results 1 to 19 of 19

Thread: How to create a database in a program using vb.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    How to create a database in a program using vb.net

    How to create a database using sql in vb 2008. Creating a database as in make it a valid one. I'm actually trying to develop a program. I've got everything in mind it's just that the database that i'm lacking and i am wondering if there's any idea to create it inside vb.net.

    p.s. I know how to link. I just need the information to create the database from the scratch using SQL.

    Those who came and read. I appreciate your time and stamina. Thanks a lot. Sincerely,

    Teng Hock

  2. #2
    Lively Member
    Join Date
    May 2008
    Posts
    75

    Re: How to create a database in a program using vb.net

    Are you connecting to a Full SQL database (server)? such as sql 2005... or are you connecting to a SQL CE/SQL Compact database (client)

    Quote Originally Posted by TengHock View Post
    How to create a database using sql in vb 2008. Creating a database as in make it a valid one. I'm actually trying to develop a program. I've got everything in mind it's just that the database that i'm lacking and i am wondering if there's any idea to create it inside vb.net.

    p.s. I know how to link. I just need the information to create the database from the scratch using SQL.

    Those who came and read. I appreciate your time and stamina. Thanks a lot. Sincerely,

    Teng Hock

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: How to create a database in a program using vb.net

    what database system you want to connect to will determine the best way to create the database.... so... yeah... we'll need to know what you plan to connect to.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    Re: How to create a database in a program using vb.net

    Quote Originally Posted by zxed View Post
    Are you connecting to a Full SQL database (server)? such as sql 2005... or are you connecting to a SQL CE/SQL Compact database (client)
    erm... This is wad i'm unsure of.
    Well this is a brief idea about my scenario.
    I've gotta create a program that keeps track of a driver's data and lorries's data. Then I've got to enter the data during run time. Be able to modify, save and update it. Apart from that i need to have a filter and search function or perhaps you call that an option in it. I've got all the logic and I've got everything i want. I'm just stuck at the database part. My so called client wants the database to be able to hold about 1000 - 2000 entries, so he asked us to make the database using SQL. Well, the program is something like a standalone program. It does not connect to the internet and it's only meant for the user using it.

  5. #5
    Lively Member
    Join Date
    May 2008
    Posts
    75

    Re: How to create a database in a program using vb.net

    Quote Originally Posted by TengHock View Post
    erm... This is wad i'm unsure of.
    Well this is a brief idea about my scenario.
    I've gotta create a program that keeps track of a driver's data and lorries's data. Then I've got to enter the data during run time. Be able to modify, save and update it. Apart from that i need to have a filter and search function or perhaps you call that an option in it. I've got all the logic and I've got everything i want. I'm just stuck at the database part. My so called client wants the database to be able to hold about 1000 - 2000 entries, so he asked us to make the database using SQL. Well, the program is something like a standalone program. It does not connect to the internet and it's only meant for the user using it.
    if the program is stand alone, and you need a database you need something like SQL CE / SQL COMPACT / SQL MOBILe., i think its currently called SQL CE., ver 3.5

    if you have VS 2008/5 you can simply add the database to ur project....

    start there

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    Re: How to create a database in a program using vb.net

    Quote Originally Posted by zxed View Post
    if the program is stand alone, and you need a database you need something like SQL CE / SQL COMPACT / SQL MOBILe., i think its currently called SQL CE., ver 3.5

    if you have VS 2008/5 you can simply add the database to ur project....

    start there
    U mean adding the database by going to Data, Add Data Source then make a new connection? After doing that configure those things there and retrieve it when i need to use it? Anyway do you know where i can download SQL Ce? is it free?

    p.s Thanks for your reply. And sorry for the late reply of mine. My internet sucks it took me ages to come here. Somehow something is wrong with the net here

  7. #7
    Lively Member
    Join Date
    May 2008
    Posts
    75

    Re: How to create a database in a program using vb.net

    Quote Originally Posted by TengHock View Post
    U mean adding the database by going to Data, Add Data Source then make a new connection? After doing that configure those things there and retrieve it when i need to use it? Anyway do you know where i can download SQL Ce? is it free?

    p.s Thanks for your reply. And sorry for the late reply of mine. My internet sucks it took me ages to come here. Somehow something is wrong with the net here
    No probs, sqlce is free.,

    The best version is 3.5., Sp1 the latest.

    It comes out of the box with be 2008, it's available with 2005 but not as good., I believe you can upgrade to latest

    Download from msdn, it's free, google it

    I'm on my phone,. Not laptop ,. I'd get I a link otherwise

  8. #8

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    Re: How to create a database in a program using vb.net

    thanks i found it already. Gonna start working on the project already haha.. Headache.. I guess it usually happens when 4 ppl's work is cramped into 1 ppl.. thanks for replying. Really appreciate it.

  9. #9

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    Re: How to create a database in a program using vb.net

    owh bad luck here. I'm using windows xp home edition. No IIS installed i guess this would be my next headache ==.

  10. #10
    Lively Member
    Join Date
    May 2008
    Posts
    75

    Re: How to create a database in a program using vb.net

    U shdnt need iis, I'll check for u in the. Morning

  11. #11

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    Re: How to create a database in a program using vb.net

    erm k thanks. In da meanwhile i found an optional method which is creating the .mdf file by using vb.net. Sweet dreams if u're already goin to sleep

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

    Re: How to create a database in a program using vb.net

    Hey,

    An mdf file, is a SQL Server Express Database. So in order to use it in your application, if you are distributing it, you will need to have SQL Server Express installed on the target machine. This is the benefit of using SQL Server Compact Edition, you don't need to have SQL Server installed, you just need to deploy the SQL Server Compact DLL's.

    What version of Visual Studio are you using? You don't need to have IIS installed, you can use the built in Web Server for testing and debugging.

    Gary

  13. #13

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    Re: How to create a database in a program using vb.net

    vs2008. Owh i see thanks for the answer. and how do i create the database? do i make a new connection and just add tables there and then link? After that, I just need to add some coding to call it right? Thanks Gary.

  14. #14
    Lively Member
    Join Date
    May 2008
    Posts
    75

    Re: How to create a database in a program using vb.net

    1. drop in the file (add), i would remove the bindings vs 2008 add's
    2. create you connection in code to the SDF., using something like
    Data Source=MyDatabaseName.sdf

    make sure you import ref to sqlce, and declare the correct object, and
    Imports System.Data.SqlServerCe

    Dim cmd As New SqlCeCommand("Select & from something", _connection)
    cmd.ExecuteScalar

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

    Re: How to create a database in a program using vb.net

    Hey,

    Are you using one of the Professional versions of Visual Studio or are you using the Express Versions? If you are deploying a SQL Server Express Database, just add a new "SQL Database" to your project. If you are doing a SQL Server Compact one, then add a new datasource, select SQL Server Compact and then go through the wizard to add a new sdf file.

    Hope that helps!!

    Gary

  16. #16

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    Re: How to create a database in a program using vb.net

    i'm using express version. So it means i'll have to just simply add one right. Just add and then call the connection.

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

    Re: How to create a database in a program using vb.net

    Hey,

    That's right, just right click on the solution, click add new item, select the SQL Database, give it a name, click ok, then a wizard will start which will let you configure everything that you want to do with the database. Since there is nothing in the database, there isn't much we can do here, so just hit finish.

    You will notice in your app.config file the connectionstring to the database is not saved. You should now be able to open the database in the Database Explorer, and to start adding the tables that you need.

    Hope that helps!!

    Gary

  18. #18

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    Re: How to create a database in a program using vb.net

    thanks for the info. I'll proceed with my project first. I'll write here again when i'm having some problems. So the thread won't be closed yet. Thanks for your help guys.

  19. #19

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    11

    Re: How to create a database in a program using vb.net

    I've uploaded the files in an attachment following to this reply. That's wad i've been working on. I've created the tables, the relations and the attributes. I've worked on the relation but i'm not sure if it's correct. Here are the information that states how this database works.

    One depot can have many lories
    One lorry belongs to only one depot
    Every driver is assigned to 1 lorry
    One lorry can only be assigned to 1 drivers
    A depot has many drivers
    One driver can only be from a depot

    I hope someone can tell me what doo i need to d with the view section. I don't know what to add there. Any ideas or suggestion?

    p.s. Really stuck with this MDF thingy.
    M.S.(must see) Thanks for attending to this issue. Your reading time and feedback are sincerely appreciated. Thanks and have a nice day. Sincerely Teng Hock.
    Attached Files Attached Files

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