two tables 1 dataset and pass to datagridview ,Incorrect syntax near
keyword as using vb.net
I have an error regarding joining two tables and 1 dataset and pass to
datgridview.. Im a noob. my flow is i want to display the selected column
in two tables and display in single datagridview row.. my query runs at
sql server management studio but when i code it in vb.net it cause an
error.. pls help me..
This is my code in sql server management studio:
Select a.CeramicLotNo,a.CeramicPartsNo, b.CerlotNo,b.MoldingLot
from tblHikLotMgtDB as a
INNER JOIN tblHikConchart as b
On a.CeramicLotNo = b.CerlotNo
where b.CerLotNO = 'W13D004-015'
then this is my code in vb.net
Private Sub btnHiSearch_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnHiSearch.Click
cerlot = Trim(txtHiSearch.Text)
dgrid.Rows.Clear()
Dim con As SqlConnection = New
SqlConnection("Server=ITS-CODER02\DIBMART; Initial Catalog =
HiKLotMgt; User Id= sa; Password = !@#;")
con.Open()
sql = "Select a.CeramicLotNo,a.CeramicPartsNo,
b.CerlotNo,b.MoldingLot" & _
"from tblHikLotMgtDB as a" & _
"INNER JOIN tblHikConChart as b" & _
"On a.CeramicLotNo = b.CerlotNo" & _
"where a.CeramicLotNo = '" & cerlot & "'"
Dim da As New SqlDataAdapter(sql, con)
Dim ds As New DataSet
da.Fill(ds, "tblHikLotMgtDB")
da.Fill(ds, "tblHikConChart")
ds.Tables("tblHikLotMgtDB").TableName = "tblHikLotMgtDB"
ds.Tables("tblHikConChart").TableName = "tblHikConChart"
dgrid.Rows.Add(ds.Tables("tblHikLotMgtDB").Columns("CeramicPartsNo"),
ds.Tables("tblHiKLotMgtDB").Columns("CeramicLotNo"),
ds.Tables("tblHikConChart").Columns("MoldingLot"),
ds.Tables("tblHikConChart").Columns("CerLotNo"))
con.Close()
End Sub
Thanks..
No comments:
Post a Comment