I'm new in c# and still learning of it. i'm setting up a phone book web to store my data to MySql database .There is none error in it ,but it came out with Server Error in '/' Application.
i have try debugging it but it still came out with the same problem
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type '_Default'.
Source Error:
Line 1: <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %>
Line 2:
Line 3:
Source File: /default.aspx Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3282.0
below are the code
namespace Phonebooks
{
public partial class _Default : Page
{
MySqlConnection connection = new MySqlConnection("datasource=localhost;port=3306;username=root;password=1234");
public _Default()
{
InitializeComponent();
}
private void BTN_INSERT_Click(object sender, EventArgs e)
{
string insertQuery = "INSERT INTO contacts(name,position,h/pno,company's name,address,post code,state,country,tel,did,fax,email) VALUES('" + txtname.Text + "','" + txtposition.Text + "'," + txthpno.Text + "','"+txtcompanyname.Text+"','"+txtadress+"','"+txtpostcode.Text+"','"+txtstate.Text+"','"+txtcountry.Text+"','"+txttel.Text+"','"+txtdirect.Text+"','"+txtfax.Text+"',"+txtemail.Text+")";
connection.Open();
MySqlCommand command = new MySqlCommand(insertQuery, connection);
try
{
if (command.ExecuteNonQuery() == 1)
{
MessageBox.Show("Data Inserted");
}
else
{
MessageBox.Show("Data Not Inserted");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
connection.Close();
}
}
}