Click here to Skip to main content
12,068,108 members (39,733 online)
 
See more: C#
I have created a form that is linked to access base (Apply Table), so what I want is when I fill the form and click the button, the information goes directly to the database, but I still have an error
Could someone check my code and fix it please


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Configuration;
using System.Data;

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

}

protected void TextBox8_TextChanged(object sender, EventArgs e)
{


}

protected void Button1_Click(object sender, EventArgs e)
{
try
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
String comandString ;

OleDbConnection con = new OleDbConnection("connStr");
OleDbDataAdapter adp = new OleDbDataAdapter();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;

adp.SelectCommand = cmd;
con.Open();
comandString = "INSERT into Apply(FirstName,LastName,Gender,DateOfBirth,CountryOfBirth,Nationality,PrimaryLanguage,NameOfCurrentSchool) values ( " + tb_FirstName.Text + " ," + tb_LastName.Text + " , " + tb_Gender.Text + " , " + tb_Birth.Text + ", " + tb_CountryOfBirth.Text + " , " + tb_Nationality.Text + " , " + tb_Language.Text + ", " + tb_School.Text + ")";

cmd.ExecuteNonQuery();
lbl_msg.Text = "Thank you for applying, we well get back to you soon.";
con.Close();
}
catch
{
lbl_msg.Text = "Error Occured.";
}
}

}

}
Closed because this exact post has already been posted by another member. Reported by Wes Aday, digimanus, Maciej Los on Tuesday, July 22, 2014 2:35am
Posted 22-Jul-14 1:00am
Zaina89160
Edited 22-Jul-14 2:35am
Wes Aday104.2K

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160208.1 | Last Updated 22 Jul 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100