Click here to Skip to main content
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 Aday94.3K

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 545
1 OriginalGriff 285
2 Shweta N Mishra 244
3 Mathew Soji 225
4 BillWoodruff 200
0 OriginalGriff 6,153
1 Sergey Alexandrovich Kryukov 5,758
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,735


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 22 Jul 2014
Copyright © CodeProject, 1999-2014
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