Results 1 to 23 of 23

Thread: [2008] Few Basic Questions

Hybrid View

  1. #1
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Few Basic Questions

    Which database you're using is pretty much irrelevant. ADO.NET code all follows the same pattern. If you're using a different database then you simply change the connection string and, perhaps, the data namespace. Follow the Data Access link in my signature for some ADO.NET code examples. As that thread says, if you're using Access you can just change SqlClient to OleDb. If you're using SQL Server CE then you just switch SqlClient to SqlServerCe.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    10

    Re: [2008] Few Basic Questions

    I seem to run into trouble at this line:

    Code:
    Dim connection As New System.Data.SqlServerCe.SqlCeConnection("Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=C:\Users\Blake\Documents\Visual Studio 2008\Projects\Ori\Ori\Database1.sdf")
    Code as a whole:

    Code:
    Dim connection As New System.Data.SqlServerCe.SqlCeConnection("Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=C:\Users\Blake\Documents\Visual Studio 2008\Projects\Ori\Ori\Database1.sdf")
            Dim command As New System.Data.SqlServerCe.SqlCeCommand("SELECT Price, Quest Item, Name FROM Items", connection)
            connection.Open()
            Dim reader As System.Data.SqlServerCe.SqlCeDataReader = command.ExecuteReader()
            While reader.Read()
                MessageBox.Show(String.Format("There are {0} {1} of {2} remaining in stock.", _
                                      reader("Quantity"), _
                                      reader("Unit"), _
                                      reader("Name")))
            End While
            reader.Close()
            connection.Close()

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