I am converting a website that uses an Access Database to SQL Server.
On one particular SqlDataSource I am having a lot of trouble. Here is
the original:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString%>"
ProviderName="<%$
ConnectionStrings:MyConnectionString.ProviderName %>"
SelectCommand="SELECT [Organization], [DocUnid] FROM
[ContactInfo]" DeleteCommand="DELETE FROM ContactInfo WHERE DocUNID
= ?"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString%>"
ProviderName="<%$
ConnectionStrings:MyConnectionString.ProviderName %>"
SelectCommand="SELECT [Organization], [DocUnid], [Notice],
[Wire] FROM [ContactInfo] WHERE ([DocUnid] = ?)" UpdateCommand="UPDATE
ContactInfo SET Organization = ?, Notice = ?, Wire = ? WHERE DocUnid
= ?">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="DocUnid"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Organization" />
<asp:Parameter Name="Notice" />
<asp:Parameter Name="Wire" />
<asp:Parameter Name="DocUnid" />
</UpdateParameters>
</asp:SqlDataSource>
To convert it I have just been changing the ?s to @wire,
@organization, @DocUnid, etc. However, this doesn't seem to be
working. When I call the delete command, it gives me "Must declare
the scalar variable '@DocUnid.'" When I declare DocUnid as a
parameter, it doesn't successfully delete.
Why would this procedure work perfectly under Access, but suddenly
breaks when using sql client? Please let me know if I am doing
something wrong in converting.