misselegant 0 Newbie Poster

thanks the problem has been solved

thanks very much for your explanation

misselegant 0 Newbie Poster

I also want it in the C# code (aspx) page & coressponding (aspx.cs)

misselegant 0 Newbie Poster

Hi guys,

I coding a page to save the first name in the database, iam having a problem and I want you to help me please..

aspx page code

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

<!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>
        <span style="font-size: 36pt"><strong><span style="text-decoration: underline">Comany
            registration</span></strong><br />
        </span>
        <br />
       First Name:
        <asp:TextBox ID="NameTextBox" runat="server"></asp:TextBox>
        
        <asp:Button ID="SubmitButton" runat="server" Text="Submit" />

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

and this is the code behind it

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
using System.Data.SqlClient;

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

    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }
    protected void submitButton_Click(object sender, EventArgs e)
    {

        SqlConnection conn = new SqlConnection();
        DateTime laiks = new DateTime();
        conn.ConnectionString = "data source=.\\SQLEXPRESS;initial catalog=CV;integrated security=true;";
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "INSERT INTO Test(Firstname) values ('" & NameTextBox.Value & "')";
        cmd.Connection = conn;
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
    }
  }

I have the error in "Value" which is attached with "NameTextBox".
I have a database which is called "Test" and table with "Test" naming.
The colume name is "Firstname" with varchar(50) type
thanks in advance

misselegant 0 Newbie Poster

Hi guys,

I tried the code and I fix it according to DB, But I still have a problem in it..

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

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

    
<html runat="server" xmlns="http://www.w3.org/1999/xhtml" >



<head runat="server">
    <title>Untitled Page</title>
</head>



<body>

    <form id="form1" runat="server">
    <div>
        <span style="font-size: 36pt"><strong><span style="text-decoration: underline">Comany
            registration</span></strong><br />
        </span>
        <br />
       First Name:
        <asp:TextBox ID="NameTextBox" runat="server"></asp:TextBox>
        
        <asp:Button ID="SubmitButton" runat="server" Text="Submit" />

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

and this is the code behind it

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
using System.Data.SqlClient;

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

    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }
    protected void submitButton_Click(object sender, EventArgs e)
    {

        SqlConnection conn = new SqlConnection();
        DateTime laiks = new DateTime();
        conn.ConnectionString = "data source=.\\SQLEXPRESS;initial catalog=CV;integrated security=true;";
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "INSERT INTO Test(Firstname) values ('" & NameTextBox.Value & "')";
        cmd.Connection = conn;
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
    }
    
  
    
}

I have the error in "Value" which is attached with "NameTextBox".
I have a database which is called "Test" and table with "Test" naming.
The colume name is "Firstname" with varchar(50) type
thanks in advance