chpicker
Programmer
- Apr 10, 2001
- 1,316
I'm trying to convert a web site from using an Access database (.wdf file) to using a SQL Server database. In general, all I've done is change instances of <asp:AccessDataSource> to <asp:SqlDataSource> and then alter the properties. This seems to be working so far except for one instance.
On our login page, we have the following structure:
I tried to just change the Access source to SQL like so:
When I click the Submit button on the login page, I get the following error: System.Data.SqlClient.SqlException: Incorrect syntax near '?'. The error occurs on this line:
I'm pretty sure this means that the parameters aren't being inserted properly from the form fields. Do the parameters work differently in SQL than they did in Access? Do I need to pass it in the VB code or will the Parameter tags work?
Ian
On our login page, we have the following structure:
Code:
<asp:AccessDataSource ID="LoginDataSource" runat="server" Datafile="webdata.wdf"
SelectCommand="SELECT * FROM users WHERE UserID = ? AND Password = ?">
<SelectParameters>
<asp:ControlParameter ControlID="txtUserID" Name="UserID" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="txtPassword" Name="Password" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
Code:
<asp:SqlDataSource ID="LoginDataSource" runat="server" ConnectionString="Data Source=192.168.1.26;Initial Catalog=MyDB;Integrated Security=True" ProviderName="System.Data.SqlClient"
SelectCommand="SELECT * FROM users WHERE UserID = ? AND Password = ?">
<SelectParameters>
<asp:ControlParameter ControlID="txtUserID" Name="UserID" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="txtPassword" Name="Password" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
Code:
Dim loginDV As DataView = CType(LoginDataSource.Select(DataSourceSelectArguments.Empty), DataView)
I'm pretty sure this means that the parameters aren't being inserted properly from the form fields. Do the parameters work differently in SQL than they did in Access? Do I need to pass it in the VB code or will the Parameter tags work?
Ian