In the web.config file I have included
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true"/>
</system.web>
this is my web.config file<connectionStrings>
Expand|Select|Wrap|Line Numbers
- <add name="conn" connectionString=" Server=xxx.db.xxxx.hostedresource.com; Database=xxx; User ID=xxx; Password=xxx; Trusted_Connection=False" providerName="System.Data.SqlClient" /> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString=" Server=xxx.db.xxxx.hostedresource.com; Database=xxx; User ID=xxx; Password=xxx; Trusted_Connection=False" providerName="System.Data.SqlClient" />
- </connectionStrings>
- <configuration>
- <system.webServer>
- <httpErrors errorMode="Detailed" />
- <asp scriptErrorSentToBrowser="true"/>
- </system.webServer>
- <system.web>
- <customErrors mode="Off"/>
- <compilation debug="true"/>
- </system.web>
- </configuration>
Expand|Select|Wrap|Line Numbers
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.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>
- <table style="position: relative">
- <tr>
- <td style="width: 100px">
- </td>
- <td style="width: 100px">
- </td>
- <td style="width: 100px">
- </td>
- </tr>
- <tr>
- <td style="width: 100px">
- <asp:TextBox ID="TextBox1" runat="server" Style="position: relative"></asp:TextBox></td>
- <td style="width: 100px">
- <asp:TextBox ID="TextBox2" runat="server" Style="position: relative"></asp:TextBox></td>
- <td style="width: 100px">
- <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="position: relative"
- Text="Button" /></td>
- </tr>
- <tr>
- <td style="width: 100px">
- </td>
- <td style="width: 100px">
- </td>
- <td style="width: 100px">
- </td>
- </tr>
- </table>
- </div>
- </form>
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- 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 _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- string aa = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
- SqlConnection con = new SqlConnection(aa);
- con.Open();
- string name = TextBox1.Text;
- string pwd = TextBox2.Text;
- string str = "insert into login values('" + name + "', '" + pwd + "', '" + pwd + "', '" + pwd + "')";
- SqlCommand cmd = new SqlCommand(str, con);
- cmd .ExecuteNonQuery ();
- }
- }