Locations of visitors to this page
Onteora Software - January 2007

Onteora Software

Ken Tucker's Blog

About the author

Author Name is someone.
E-mail me Send mail

Recent posts

Recent comments

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Unable to Update Database added to Project

Unable to Update Database added to Project



I see from time to time people complaining they can not update an database they added to their Visual Studio 2005 project. Sometimes your database is actually getting updated but Visual Studio is copying the old version of the database over the updated version. You should check and make sure the Database's Copy to Output property is not set to Copy Always. It should be set to Copy if newer.



Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Ado.Net
Posted by Ken Tucker on Monday, January 22, 2007 11:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Inner Join with 2 or more tables

Inner Join with 2 or more tables



If you are getting data from more than 2 tables you need to surround the inner joins in brackets. For this example I am using the just released SQL Compact Edition. You will find a sample NorthWind database in the sdk. Note to work with a SQL CE database you need to add a reference to the System.Data.Sqlce.dll you find in the directory you installed sql server ce.


Imports System.Data.SqlServerCe
Imports System.Text
 
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim conn As New SqlCeConnection("data source='NorthWind.sdf'; mode=Exclusive;")
        Dim sbCommand As New StringBuilder
        Dim dt As New DataTable
        sbCommand.Append("Select Orders.[Customer ID], Products.[Product Name], [Order Details].Quantity, [Order Details].[Unit Price] From ")
        sbCommand.Append("(Orders Inner Join [Order Details] on Orders.[Order ID] = [Order Details].[Order ID]) ")
        sbCommand.Append("Inner Join Products on [Order Details].[Product ID]= Products.[Product ID]")

        Dim da As New SqlCeDataAdapter(sbCommand.ToString, conn)
        da.Fill(dt)
        DataGridView1.DataSource = dt
        With DataGridView1.Columns("Unit Price").DefaultCellStyle
            .Format = "c"
            .Alignment = DataGridViewContentAlignment.MiddleRight
        End With
    End Sub
End Class

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Ado.Net | VB
Posted by Ken Tucker on Friday, January 19, 2007 11:12 PM
Permalink | Comments (0) | Post RSSRSS comment feed