IOB
03-01-2007, 08:06 PM
When I use the proper SQL statements within ADO to insert a record into my test database using parameters (values from textboxes), nothing is passed at all and everything is null. However, if I pass a hard value, the table does recieve the data. I looked over my code a bunch of times but can't find one thing wrong as to why this is happening. Any help?
<%@ Import Namespace = "MySql.Data.MySqlClient"%>
<%@ Page Language="C#" Debug="true" %>
<Script Runat="server">
protected void submitClick(object s, EventArgs e){
MySqlConnection conn;
MySqlCommand comm;
conn=new MySqlConnection("Server=localhost;user id=testuser;pwd=password;database=test");
comm = new MySqlCommand(
"INSERT INTO Dev07 (cliID)" +
"VALUES (@cliID)", conn);
comm.Parameters.Add("@cliID",clientTextBox.Text);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
}
</script>
<html>
<body>
<form Runat="Server">
<p>
Account Number
<asp:TextBox
Id="clientTextBox"
MaxLength="7"
Runat="Server" />
<p>
<asp:Button
Id="submit"
OnClick="submitClick"
Text="submit"
runat="server" />
</form>
</body>
</html>
<%@ Import Namespace = "MySql.Data.MySqlClient"%>
<%@ Page Language="C#" Debug="true" %>
<Script Runat="server">
protected void submitClick(object s, EventArgs e){
MySqlConnection conn;
MySqlCommand comm;
conn=new MySqlConnection("Server=localhost;user id=testuser;pwd=password;database=test");
comm = new MySqlCommand(
"INSERT INTO Dev07 (cliID)" +
"VALUES (@cliID)", conn);
comm.Parameters.Add("@cliID",clientTextBox.Text);
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
}
</script>
<html>
<body>
<form Runat="Server">
<p>
Account Number
<asp:TextBox
Id="clientTextBox"
MaxLength="7"
Runat="Server" />
<p>
<asp:Button
Id="submit"
OnClick="submitClick"
Text="submit"
runat="server" />
</form>
</body>
</html>