i have a code that points to one line, i have used my error trap, to trap it and it gave me an Error, that i dont see where it points to,here is the code
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strconnection As String = "workstation id=5875-049;packet size=4096;user id=sde;Password=topology;data source=SGIICORNETGS01;persist security info=False;initial catalog=Tshwane_Valuations"
Dim cn As SqlConnection = New SqlConnection(strconnection)
cn.Open()
'set up data adapter
Dim strSql As String = _
"select Boundary_Area,Actual_Extent," _
& "Attrib_code,Lis_key,Func_key," _
& "Density,New_Net_Usable_Extent," _
& "New_Total_Land_Factor,New_AdJ_Extent_1," _
& "New_Points_1,New_ADJ_Extent_2," _
& "New_Points_2,Fin_Ls_Prediction," _
& "Confidence_score,Flagtype from Property_Mass"
Dim strErrorMsg As String
Dim strerror As System.Data.SqlClient.SqlError
Try
Dim da As SqlDataAdapter = New SqlDataAdapter(strSql, cn)
'Declare and load the Data set
Dim ds As DataSet = New DataSet
da.Fill(ds, "Property_Mass")
'set up data Adapter Object
strSql = _
"select Property_Mass.Boundary_Area,Property_Mass.Actual_Extent,Property_Mass.Attrib_code,Property_Mass.Lis_key,Property_Mass.Func_key,Property_Mass.Density," _
& "Property_Mass.New_Net_Usable_Extent,Property_Mass.New_Total_Land_Factor,Property_Mass.New_AdJ_Extent_1,Property_Mass.New_Points_1,Property_Mass.New_ADJ_Extent_2,Property_Mass.New_Points_2,Property_Mass.Fin_Ls_Prediction,Property_Mass.Confidence_score,Property_Mass.Flagtype,Property_Summary.Purchase_Date,Property_Summary.Purchase_Price" _
& "from(Property_Mass, Property_Summary)" _
& "where(Property_Mass.Lis_key = Property_Summary.Lis_key)"
da = New SqlDataAdapter(strSql, cn)
'load a Dataset
da.Fill(ds, "Property_Mass")
'Close the Connection
'cn.Close()
'Create relations
ds.Relations.Add("Property_summary_Mass", _
ds.Tables("Property_Mass").Columns("Lis_key"), _
ds.Tables("Property_Summary").Columns("Lis_key"))
'Bind the data set to the grid.
'Assumes that Grid contains a reference to a
'system.windows.datagrid
DataGrid2.SetDataBinding(ds, "Property_Mass")
'sorting the Datagrid
'DataGrid2.AllowSorting = True
Catch ExSQL As System.Data.SqlClient.SqlException
' '''All this will trap all data Problems and Network if available
For Each strerror In ExSQL.Errors
Next
Select Case strerror.Number
Case 17
strErrorMsg = "Missing server"
Case 4060
strErrorMsg = "Missing database"
Case 18456
strErrorMsg = "Missing user name or password"
Case Else
strErrorMsg = strerror.Message
End Select
MessageBox.Show(strErrorMsg, "SQL Server Error: " & strerror.Number, MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch ExcpInvOp As System.InvalidOperationException
MessageBox.Show("Close the connection first!", "Invalid Operation", MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch Excp As System.Exception ' generic exception handler
MessageBox.Show(Excp.Message, "Unexpected Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub btnliskey_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnliskey.Click
'Open Database Connection
Dim strconnection As String = "workstation id=5875-049;packet size=4096; user id=###; Password=######; data source=########;persist security info=False;initial catalog=Tshwane_Valuations"
Dim cn As SqlConnection = New SqlConnection(strconnection)
cn.Open()
'set up data adapter
Dim strSql As String = _
"select Actual_Extent,Attrib_code,Lis_key,Func_key,Density," _
& "New_Net_Usable_Extent,New_Total_Land_Factor,New_AdJ_Extent_1,New_Points_1," _
& "New_ADJ_Extent_2, New_Points_2, LS_Prediction, LS_Confidence,LS_TYPE from Property_Mass "
Dim da As SqlDataAdapter = New SqlDataAdapter(strSql, cn)
' Load(DataSet)
Dim ds As DataSet = New DataSet
da.Fill(ds, "Property_Mass")
'Set up a new Data adapter Object
strSql = _
"select Property_Mass.Actual_Extent,Property_Mass.Attrib_code,Property_Mass.Lis_key,Property_Mass.Func_key,Property_Mass.Density," _
& " Property_Mass.New_Net_Usable_Extent,Property_Mass.New_Total_Land_Factor,Property_Mass.New_AdJ_Extent_1, Property_Mass.New_Points_1," _
& " Property_Mass.New_ADJ_Extent_2, Property_Mass.New_Points_2, Property_Mass.LS_Prediction, Property_Mass.LS_Confidence, Property_Mass.LS_TYPE," _
& " Property_Summary.Purchase_Date, Property_Summary.Purchase_Price" _
& " from Property_Mass, Property_Summary" _
& "where Substring(Lis_key,1,4) LIKE @Pattern"
da.SelectCommand.Parameters("Lis_key").Value = txtliskeysearch.Text
If ds.Tables("Property_Mass").Rows.Count = 0 Then
MessageBox.Show("Township not Found")
Else
da.Fill(ds)
End If
And this is the Error
The Column Prefix 'Property_Summary' does not match with the table name or Alias name used in this Query.
Thanks you
Vuyiswa Maseko
|