Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incorrect syntax near '.' message

Status
Not open for further replies.

stillwillyboy

Technical User
Jan 22, 2004
165
US
I am trying to join three tables and pull some info. With the following code, I keep getting an Exception error stating Incorrect syntax near '.'. The exception error is pointing at the line: m_daDataAdapter.Fill(m_dtClients)

(Please note that there are proper line continuations in my code, but the formatting changes when copying and pasting.)

I have looked and looked and can't see the problem. Any help will be rewarded. Thanks, Bill.

Code:
Public Class frmConnectToSQLTest
    Private m_cnADONetConnection As New System.Data.SqlClient.SqlConnection()
    Private m_daDataAdapter As SqlClient.SqlDataAdapter
    Private m_cbCommandBuilder As SqlClient.SqlCommandBuilder
    Private m_dtClients As New DataTable
    Private m_rowPosition As Integer = 0

Private Sub frmConnectToSQLTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

m_cnADONetConnection.ConnectionString = _
"Data Source=B-7M2KXC45F9FT4\SQLEXPRESS;Initial Catalog=ClientPayroll;Trusted_Connection=yes;User Id=B-7M2KXC45F9FT4\administrator"

       m_cnADONetConnection.Open()

m_daDataAdapter = New SqlClient.SqlDataAdapter("Select " & _
"tbl_ClntBasicInfo.ClientNumber, tbl_ClntBasicInfo.LastName, " & _
"tbl_ClntBasicInfo.FirstName, tbl_ClntBasicInfo.MiddleInitial, " & _
"tbl_ClntPayRates.Average, tbl_ClntPayRates.Fringe " & _
"tbl_ClntClientBranch.BranchNumber " & _
"FROM (tbl_ClntBasicInfo " & _
"Inner Join tbl_ClntPayRates " & _
"ON tbl_ClntBasicInfo.ClientNumber = tbl_ClntPayRates.ClientNumber )" & _
"INNER JOIN tbl_ClntClientBranch " & _
"ON tbl_ClntBasicInfo.ClientNumber = tbl_ClntClientBranch.ClientNumber", m_cnADONetConnection)

        m_cbCommandBuilder = New SqlClient.SqlCommandBuilder(m_daDataAdapter)
        m_daDataAdapter.Fill(m_dtClients)
        Me.ShowCurrentRecord()

End Sub

Private Sub frmConnectToSQLTest_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        m_cnADONetConnection.Close()
        m_cnADONetConnection.Dispose()

End Sub

Private Sub ShowCurrentRecord()
        If m_dtClients.Rows.Count = 0 Then
            txtClientNumber.text = ""
            txtLastName.text = ""
            txtFirstName.Text = ""
            txtMiddleInitial.Text = ""
            txtAverage.Text = ""
            txtFringe.Text = ""
            txtLocation.Text = ""
            Exit Sub
        End If

txtClientNumber.text = _
m_dtClients.Rows(m_rowPosition)("ClientNumber").ToString

txtLastName.Text = _
m_dtClients.Rows(m_rowPosition)("LastName").ToString

txtFirstName.Text = _
m_dtClients.Rows(m_rowPosition)("FirstName").ToString()

txtMiddleInitial.Text = _
m_dtClients.Rows(m_rowPosition)("MiddleInitial").ToString()

txtAverage.Text = _
m_dtClients.Rows(m_rowPosition)("Average").ToString()

txtFringe.Text = _
m_dtClients.Rows(m_rowPosition)("Fringe").ToString()

txtLocation.Text = _
m_dtClients.Rows(m_rowPosition)("BranchNumber").ToString()

End Sub
End Class
 
This is a vb.net question. You should post this question in the vb.net forum: forum796

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top