FormView Control in ASP.NET 2.0 beta2 with MySQL



I seem unable to get the FormView with the SqlDataSource control in ASP.NET
2.0 beta 2 to insert into my MySQL 4.11 database corectly. When I run the
page and click on the Insert link a SQL insert happens and a record gets
inserted into my MySQL table but every field that is inserted is NULL.

I have a feeling it I am referancing the values incorrectly with my
InsertCommand. Here is the insert command:

InsertCommand="insert into guestbook (firstname,lastname,city) values

Any help pn this would be very much appreciated,

Here is my table defination:

CREATE TABLE `guestbook` ( `autoid` int(10) unsigned NOT NULL
auto_increment, `firstname` varchar(30) default NULL, `lastname` varchar(30)
default NULL, `emailaddress` varchar(60) default NULL, `city` varchar(30)
default NULL, `prov` varchar(30) default NULL, `country` varchar(30) default
NULL, `comments` text, `ipaddress` varchar(20) default NULL, `addtime`
datetime default '0000-00-00 00:00:00', PRIMARY KEY (`autoid`), UNIQUE KEY
`autoid` (`autoid`), KEY `autoid_2` (`autoid`))

Below is my code:
<%@ Page Language="VB" CodeFile="newentry.aspx.vb" Inherits="newentry" %>


<html xmlns="" >
<head runat="server">
<title>Untitled Page</title>
<form id="form1" runat="server">
<asp:FormView ID="FormView1" runat="server"
DataSourceID="SqlDataSource1" DefaultMode="Insert" DataKeyNames="autoid"
<asp:TextBox ID="firstnameTextBox" runat="server"
Text='<%# Bind("firstname") %>'>
<asp:TextBox ID="lastnameTextBox" runat="server"
Text='<%# Bind("lastname") %>'>
<asp:TextBox ID="emailaddressTextBox" runat="server"
Text='<%# Bind("emailaddress") %>'>

<asp:TextBox ID="countryTextBox" runat="server"
Text='<%# Bind("country") %>'>
<asp:TextBox ID="provTextBox" runat="server" Text='<%#
Bind("prov") %>'>
<asp:TextBox ID="cityTextBox" runat="server" Text='<%#
Bind("city") %>'>
<asp:TextBox ID="commentsTextBox" runat="server"
Text='<%# Bind("comments") %>' TextMode="MultiLine"
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:www_sarnia_comConnectionString %>"
ConnectionStrings:www_sarnia_comConnectionString.ProviderName %>"
InsertCommand="insert into guestbook (firstname,lastname,city)
values (@firstname,@lastname,@city)">


Hmm, you might want to try to use a GridView to configure the source.
Once information comes up on that, go to the FormView and make sure
that the value of "DataKeyNames" is the same as that of the GridView.
Fell free to contact me if you want more info. I don't visit here much.
=D (e-mail address removed)

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question