How can I read from selected database.table.column using INNER JOIN with same name but different data.Code:cmd = New SqlCommand("SELECT AlarmDate, OperCode, AcctNum, Name, AlarmZones, Number, ZL.Description, SC.Description FROM " & xDateReport & " as SH " _ & "INNER JOIN Subscriber.dbo.[Subscriber Data] as SD " _ & "ON " _ & "SH.AccountID = SD.AccountID " _ & "INNER JOIN Subscriber.dbo.[Zone Lists] as ZL " _ & "ON " _ & "SH.AccountID = ZL.AccountID " _ & "INNER JOIN MISCELLANEOUS.dbo.[Signal Codes] as SC " _ & "ON " _ & "SH.AlarmCode COLLATE DATABASE_DEFAULT = SC.Code " _ & " where AlarmDate between '" & Fdate1 & "00:00:00' and '" & Fdate2 & "23:59:59' and AlarmZones COLLATE DATABASE_DEFAULT = LTRIM(RTRIM(Number)) order by AlarmDate ASC ", SQLConn) dr = cmd.ExecuteReader Do While dr.Read DataGridView1.Rows.Add(Format(dr("AlarmDate")), dr("OperCode"), dr("AcctNum"), dr("Name"), dr("AlarmZones"), dr(ZL."Description"), dr(SC."Description")) Loop dr.Close()
Thanks


Reply With Quote
