<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="id"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="id" HeaderText="编号"/>
<asp:BoundField DataField="name" HeaderText="姓名"/>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString=" <%$ ConnectionStrings:ExcelConnectionString %>"
ProviderName=" <%$ ConnectionStrings:ExcelConnectionString.ProviderName %>"
SelectCommand="select id, name from [test$] where id is not null"
DeleteCommand="UPDATE [test$] SET name = NULL, id= NULL WHERE id = @id">
<DeleteParameters>
<asp:Parameter name="id" Type="Int32"/>
</DeleteParameters>
</asp:SqlDataSource>
__________________________________________________________________
web.config
<connectionStrings>
<add name="ExcelConnectionString" connectionString="Dsn=tset;dbq=D:\MY DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\WEBTEST\APP_DATA\test.xls;defaultdir=D:\MY DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\WEBTEST\APP_DATA;driverid=790;fil=excel 8.0;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc"/>
</connectionStrings>
__________________________________________________________________
连接的是个Excel文件
DeleteCommand 中的@id 改为 具体数字没有问题,当前错误是 “ERROR [07002] [Microsoft][ODBC Excel Driver] 参数不足,期待是 1。”
怎样用当前这种方式实现删除,或者是为什么会有这种错误?<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="id"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="id" HeaderText="编号"/>
<asp:BoundField DataField="name" HeaderText="姓名"/>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString=" <%$ ConnectionStrings:ExcelConnectionString %>"
ProviderName=" <%$ ConnectionStrings:ExcelConnectionString.ProviderName %>"
SelectCommand="select id, name from [test$] where id is not null"
DeleteCommand="UPDATE [test$] SET name = NULL, id= NULL WHERE id = @id">
<DeleteParameters>
<asp:Parameter name="id" Type="Int32"/>
</DeleteParameters>
</asp:SqlDataSource>
__________________________________________________________________
web.config
<connectionStrings>
<add name="ExcelConnectionString" connectionString="Dsn=tset;dbq=D:\MY DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\WEBTEST\APP_DATA\test.xls;defaultdir=D:\MY DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\WEBTEST\APP_DATA;driverid=790;fil=excel 8.0;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc"/>
</connectionStrings>
__________________________________________________________________
连接的是个Excel文件
DeleteCommand 中的@id 改为 具体数字没有问题,当前错误是 “ERROR [07002] [Microsoft][ODBC Excel Driver] 参数不足,期待是 1。”
怎样用当前这种方式实现删除,或者是为什么会有这种错误?<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="id"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="id" HeaderText="编号"/>
<asp:BoundField DataField="name" HeaderText="姓名"/>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString=" <%$ ConnectionStrings:ExcelConnectionString %>"
ProviderName=" <%$ ConnectionStrings:ExcelConnectionString.ProviderName %>"
SelectCommand="select id, name from [test$] where id is not null"
DeleteCommand="UPDATE [test$] SET name = NULL, id= NULL WHERE id = @id">
<DeleteParameters>
<asp:Parameter name="id" Type="Int32"/>
</DeleteParameters>
</asp:SqlDataSource>
__________________________________________________________________
web.config
<connectionStrings>
<add name="ExcelConnectionString" connectionString="Dsn=tset;dbq=D:\MY DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\WEBTEST\APP_DATA\test.xls;defaultdir=D:\MY DOCUMENTS\VISUAL STUDIO 2008\WEBSITES\WEBTEST\APP_DATA;driverid=790;fil=excel 8.0;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc"/>
</connectionStrings>
__________________________________________________________________
连接的是个Excel文件
DeleteCommand 中的@id 改为 具体数字没有问题,当前错误是 “ERROR [07002] [Microsoft][ODBC Excel Driver] 参数不足,期待是 1。”
怎样用当前这种方式实现删除,或者是为什么会有这种错误?
建议你使用ODBC数据源。 要么你把这个文件包含到项目中,然后使用相对路径。
http://www.cnblogs.com/downmoon/archive/2009/01/16/1376702.html
注意连接串参数