# Intro to SQL Server with ASP.NET

**URL:** https://forum.kirupa.com/t/intro-to-sql-server-with-asp-net/221361
**Category:** programming
**Created:** [April 3, 2007, 5:10pm UTC](https://forum.kirupa.com/t/intro-to-sql-server-with-asp-net/221361 "2007-04-03T17:10:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![raithedavion](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/raithedavion/32/3427_2.png) [@raithedavion](https://forum.kirupa.com/u/raithedavion)
#### Post date: [April 3, 2007, 5:10pm UTC](https://forum.kirupa.com/t/intro-to-sql-server-with-asp-net/221361/1 "2007-04-03T17:10:36Z")

</div>

I was following the tutorial, Intro to SQL Server with [ASP.NET](http://ASP.NET), and got to where I was suppose to add the highlighted code. For starters I don’t have a file called games.aspx.cs, its just games.aspx. In addition to this, the code I see on my screen doesn’t have any of the Using systems already there.

Here is what my code looks like, can someone tell me what I did wrong?

\<%@ Page Language=“C#” %\>

\<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)”\>  
\<script runat=“server”\>

```
public partial class dbTest_Insert : System.Web.UI.Page
{

    SqlConnection connection;
    protected void Page_Load(object sender, EventArgs e)
    {

        connection = new SqlConnection(ConfigurationManager.ConnectionStrings["GamesConnection"].ConnectionString);

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

        SqlCommand command = new SqlCommand("INSERT INTO gameTable(gameName, gamePlatform) VALUES (@id_gameName, @id_gamePlatform)", connection);

        SqlParameter nameContent = new SqlParameter("@id_gameName", SqlDbType.VarChar);
        nameContent.Value = txtGameName.Text;
        command.Parameters.Add(nameContent);

        SqlParameter platformContent = new SqlParameter("@id_gamePlatform", SqlDbType.VarChar);
        platformContent.Value = txtGamePlatform.Text;
        command.Parameters.Add(platformContent);

        connection.Open();
        command.BeginExecuteNonQuery();
        connection.Close();

        Response.Redirect("Results.aspx");

    }

}

protected void btnSubmit_Click(object sender, EventArgs e)
{

}

```

\</script\>

\<html xmlns=“[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)” \>  
\<head runat=“server”\>  
\<title\>Untitled Page\</title\>  
\</head\>  
\<body\>  
\<form id=“form1” runat=“server”\>  
\<div style=“text-align: right”\>  
\<asp:SqlDataSource ID=“SqlDataSource1” runat=“server” ConnectionString="\<%$ ConnectionStrings:GamesConnection %\>"  
SelectCommand=“SELECT \* FROM [gameTable]”\>\</asp:SqlDataSource\>  
\<br /\>  
Game Name:\<asp:TextBox ID=“txtGameName” runat=“server” OnTextChanged=“txtGameName\_TextChanged”\>\</asp:TextBox\>\<br /\>  
\<br /\>  
Game Platform:  
\<asp:TextBox ID=“txtGamePlatform” runat=“server”\>\</asp:TextBox\>  
\<br /\>  
\<br /\>  
\<br /\>  
\<asp:Button ID=“btnSubmit” runat=“server” Text=“Submit” OnClick=“btnSubmit\_Click” /\>\</div\>  
\</form\>  
\</body\>  
\</html\>
