473,466 Members | 1,430 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

FormView Update Using Sybase DataProvider

I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that
accesses a Sybase database back end. We're using Sybase SQL Anywhere
9.0.2.3228. I have installed and registered the Sybase .NET 2.0
DataProvider (iAnywhere.Data.AsaClient.dll) into the GAC so it can be
used in the ProviderName property of a SQLDataSource and loads properly
at run time.

The application I'm writing is a bit more complex than the example I'm
about to show, but this is a simplified example that demonstrates the
problem I'm encountering.

I have a SQLDataSource configured with a connection string and the
Sybase DataProvider. I am using a FormView to display and allow
editing of member records in the Members table. Connecting to and
issuing a Select query, and displaying the results in the ItemTemplate
and EditItemTemplate work without any problems.

The problem occurs when I try to issue an Update query. With the code
directly below I get the error "iAnywhere.Data.AsaClient.AsaException:
Column '@Unique_ID' not found." Here is the code that causes that
error:

(FormView.aspx)

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="FormView.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<asp:SqlDataSource ID="MembersDataSource" runat="server"
ProviderName="iAnywhere.Data.AsaClient" ConnectionString="<%$
ConnectionStrings:CSQL5 %>" SelectCommand="SELECT [Unique_ID],
[MemNum], [FName], [LName] FROM [Members] WHERE [Deleted] IS NULL AND
[Type] = 'M'" EnableCaching="True" UpdateCommand="UPDATE [Members] SET
[MemNum]=@MemNum, [FName]=@FName, [LName]=@LName WHERE
[Unique_ID]=@Unique_ID">
</asp:SqlDataSource>
<br />
<br />
&nbsp;<asp:FormView ID="FormView1" runat="server"
AllowPaging="True" BackColor="White"
BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px"
CellPadding="4" DataSourceID="MembersDataSource"
GridLines="Both" DataKeyNames="Unique_ID">
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<EditRowStyle BackColor="#009999" Font-Bold="True"
ForeColor="#CCFF99" />
<RowStyle BackColor="White" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399"
HorizontalAlign="Left" />
<ItemTemplate>
MemNum:
<asp:Label ID="Label1" runat="server"
Text='<%#Eval("MemNum")%>'></asp:Label><br />
Last Name:
<asp:Label ID="Label2" runat="server"
Text='<%#Eval("LName")%>'></asp:Label><br />
First Name:
<asp:Label ID="Label3" runat="server"
Text='<%#Eval("FName")%>'></asp:Label><br />
<br />
<asp:Button ID="Button1" runat="server"
CommandName="Edit" Text="Edit" />
</ItemTemplate>
<HeaderStyle BackColor="#003399" Font-Bold="True"
ForeColor="#CCCCFF" />
<EditItemTemplate>
MemNum:
<asp:TextBox ID="TextBox3" runat="server" Text='<%#
Bind("MemNum") %>' Width="135px"></asp:TextBox><br />
Last Name:
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("LName") %>' Width="135px"></asp:TextBox><br />
First Name:
<asp:TextBox ID="TextBox2" runat="server" Text='<%#
Bind("FName") %>' Width="135px"></asp:TextBox><br />
UniqueID:
<asp:TextBox ID="MemID" runat="server" Text='<%#
Bind("Unique_ID") %>' ReadOnly="True" Width="135px"></asp:TextBox><br
/>
<br />
<asp:Button ID="Button2" runat="server"
CommandName="Update" Text="Update" />
<asp:Button ID="Button3" runat="server"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
</asp:FormView>

</div>
</form>
</body>
</html>

(FormView.aspx.cs)

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
}
So I figured I could assign the Unique_ID in the Where clause manually
and avoid the problem. That just caused the application to error in a
very similar way on a different column. Here is the error I get when
manually assigning the Unique_ID in the Update statement:
"iAnywhere.Data.AsaClient.AsaException: Column '@MemNum' not found."
Here is the code that causes this error:

(FormView.aspx)

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="FormView.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<asp:SqlDataSource ID="MembersDataSource" runat="server"
ProviderName="iAnywhere.Data.AsaClient" ConnectionString="<%$
ConnectionStrings:CSQL5 %>" SelectCommand="SELECT [Unique_ID],
[MemNum], [FName], [LName] FROM [Members] WHERE [Deleted] IS NULL AND
[Type] = 'M'" EnableCaching="True" UpdateCommand="UPDATE [Members] SET
[MemNum]=@MemNum, [FName]=@FName, [LName]=@LName WHERE [Unique_ID]=">
</asp:SqlDataSource>
<br />
<br />
&nbsp;<asp:FormView ID="FormView1" runat="server"
AllowPaging="True" BackColor="White"
BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px"
CellPadding="4" DataSourceID="MembersDataSource"
GridLines="Both" DataKeyNames="Unique_ID"
OnItemUpdating="MemberUpdating">
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<EditRowStyle BackColor="#009999" Font-Bold="True"
ForeColor="#CCFF99" />
<RowStyle BackColor="White" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399"
HorizontalAlign="Left" />
<ItemTemplate>
MemNum:
<asp:Label ID="Label1" runat="server"
Text='<%#Eval("MemNum")%>'></asp:Label><br />
Last Name:
<asp:Label ID="Label2" runat="server"
Text='<%#Eval("LName")%>'></asp:Label><br />
First Name:
<asp:Label ID="Label3" runat="server"
Text='<%#Eval("FName")%>'></asp:Label><br />
<br />
<asp:Button ID="Button1" runat="server"
CommandName="Edit" Text="Edit" />
</ItemTemplate>
<HeaderStyle BackColor="#003399" Font-Bold="True"
ForeColor="#CCCCFF" />
<EditItemTemplate>
MemNum:
<asp:TextBox ID="TextBox3" runat="server" Text='<%#
Bind("MemNum") %>' Width="135px"></asp:TextBox><br />
Last Name:
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("LName") %>' Width="135px"></asp:TextBox><br />
First Name:
<asp:TextBox ID="TextBox2" runat="server" Text='<%#
Bind("FName") %>' Width="135px"></asp:TextBox><br />
UniqueID:
<asp:TextBox ID="MemID" runat="server" Text='<%#
Bind("Unique_ID") %>' ReadOnly="True" Width="135px"></asp:TextBox><br
/>
<br />
<asp:Button ID="Button2" runat="server"
CommandName="Update" Text="Update" />
<asp:Button ID="Button3" runat="server"
CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
</asp:FormView>

</div>
</form>
</body>
</html>

(FormView.aspx.cs)

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void MemberUpdating(object sender,
FormViewUpdateEventArgs e)
{
MembersDataSource.UpdateCommand +=
e.Keys["Unique_ID"].ToString();
}

}
As far as I can tell, the values for the columns are not getting
updated with the input from the fields that I've bound using
Bind(string). I've tested to make sure, and the new values do exist
properly in the FormViewUpdateEventArgs.NewValues collection. If I
remove the @ prefix before the variables in the UpdateCommand, then the
application executes without throwing any exceptions, but no data is
ever updated.

My best guess is that there is a problem with the Sybase DataProvider,
but perhaps there is some other cause, or at least some way I can work
around this to get the field data to bind properly and not have to
manually code the UpdateCommand. Any ideas?

Jan 13 '06 #1
0 2168

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ottar | last post by:
I have a few numeric fields, and when I update i get the error: "Input string was not in a correct format". Next line:" System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&...
3
by: Michael Glass | last post by:
I'm working on an ASP.Net web app using VS2005 and the .Net 2.0 framework, and I have a serious problem with the page I'm currently working on. The page has, among other things, two FormViews and a...
3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
3
by: Jurgen Appelo | last post by:
I asked this question earlier, but unfortunately the two replies I got did not solve the problem. Here it is again, but now with the code: After an Update my FormView always loses its viewstate...
0
by: DC | last post by:
The problem I'm using the .NET GridView and FormView objects for the first time and im getting the error "An OleDbParameter with ParameterName '@ID' is not contained by this...
0
by: sanjeev06 | last post by:
When Updating using a FormView and ObjectDataSource, the formview always does the data-binding of its controls and the field values in the FormView are always overwritten by the results of the...
3
by: J055 | last post by:
Hi I have a PlaceHolder control inside a FormView EditItemTemplate: <asp:PlaceHolder ID="phResponseText" runat="server"> <tr> <td> <asp:Label ID="lblResponseText"...
8
by: =?Utf-8?B?QXNo?= | last post by:
Hi, I have an object, for example User. User contains various properties which i have been able to bind to successfully using wizards and the form view. However if the class User has a property...
3
by: KaOne | last post by:
Hi All, excuse me in advance for my not very perfect english. I need some help about a problem with a FormView bounded to an ObjectDataSource. In practise I have an ObjectDataSource that uses some...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.