473,219 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

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 2145

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...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.