Incorrect syntax - Please help!!

  • Thread starter Thread starter Teep
  • Start date Start date
T

Teep

Please help, I don't know how to correct this error. I have tried
looking at other posts, but I still can't fix this. Thanks for any
help.

Line 1: Incorrect syntax near '='.
Error message:

Line 28:
Line 29: DS = new DataSet()
Line 30: MyCommand.Fill(ds, "tbl_ap_vendors")
Line 31:
Line 32: MyDataGrid.DataSource=ds.Tables("tbl_ap_vendors").DefaultView





<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)
if not Page.IsPostBack then
doData()
end if
End Sub

Sub doQuery(Source as Object, E as EventArgs)
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter
Dim splr_name as string
splr_name=suppliername.SelectedItem.Text
'label1.text="State queried is : " & splr_name
Label1.Text="You chose: " + splr_name

Dim MySQL as string
MySQL="AP_websp_CorpEx_SplrList='" & splr_name & "'"
panel1.visible="true"
label2.text=MySQL
MyConnection = New SqlConnection("server=abcdserver;database=acct_payable;
Trusted_Connection=True;")
MyCommand = New SqlDataAdapter(MySQL, MyConnection)

DS = new DataSet()
MyCommand.Fill(ds, "tbl_ap_vendors")

MyDataGrid.DataSource=ds.Tables("tbl_ap_vendors").DefaultView
MyDataGrid.DataBind()


End Sub

Sub doData()
Dim strConn as string ="server=abcdserver;database=acct_payable;
Trusted_Connection=True"
Dim Conn as new SQLconnection(strConn)

Dim strSQL as string ="select distinct splr_name from tbl_ap_vendors"
Dim Cmd as New SQLCommand(strSQL,Conn)
Conn.Open()
suppliername.DataSource = Cmd.ExecuteReader()
suppliername.DataBind()
End Sub
</script>

<body>

<h3><font face="Verdana">Search & Database - Display Results in a
DataGrid Control</font></h3>
<Form id="form" runat="server">
<asp:DropDownList id="suppliername" datatextfield="splr_name"
runat="server" />
<asp:Button id="button" Text="Select Supplier Name" onclick="doQuery"
runat="server" />
</Form>
<asp:Panel ID="Panel1" runat="server" visible="False">
<hr>

<div align="center"><b><i>Search Results</i></b>
<asp:Label ID="label1" runat="server" /><br>
<asp:Label ID="label2" runat="server" /><p>

<ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
</div>
</asp:Panel>

</body>
</html>
 
Are you receiving the error as an SqlException? To me it does not look like you are using valid SQL (in the variable 'MySQL') so the error is actually coming from your SQL Server which is having problems parsing the SQL

Regards, Jakob.
 
Back
Top