Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 22, 2012 11:01 AM by bbcompent1
Member
14 Points
12 Posts
Feb 21, 2012 05:50 PM|LINK
see creating r typing such a big query is im possible,, so only i just copied from the query windowwwwww
Star
13431 Points
2535 Posts
Feb 22, 2012 05:54 AM|LINK
You are missing a ) at the end of the statement.
Notice that you have a ( at the start of the list of columns but no matching ) at the end.
All-Star
33063 Points
8516 Posts
Moderator
Feb 22, 2012 11:01 AM|LINK
Here is the code with the correction to the missing parenthesis.
namespace Waafe_version_1._0 { public partial class adminaddsemester : System.Web.UI.Page { private List<String> year = new List<String>(); private List<String> semester = new List<String>(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownList2.DataSource = GetYears(); DropDownList2.DataBind(); DropDownList1.DataSource = Getsemester(); DropDownList1.DataBind(); } } public List<String> GetYears() { string startingYear = "2000"; DateTime startYear = Convert.ToDateTime("01/01/" + startingYear); for (int i = 0; i < 20; i++) { int year1 = startYear.AddYears(i).Year; int year2 = startYear.AddYears(i + 4).Year; String yearfinal = year1.ToString() + year2.ToString(); year.Add(yearfinal); } return year; } public List<String> Getsemester() { for (int i = 1; i < 9; i++) { string year1 = "semester" + i; semester.Add(year1); } return semester; } protected void LinkButton1_Click(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=SARATH-31201114\\SQLEXPRESS;Initial Catalog='" + DropDownList2.SelectedValue + "' ;User ID=sa;Password=T0Ge+Da+a"); con.Open(); if (DropDownList1.SelectedValue == "semester1") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER1]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [HS2111Technicalenglish1] [char](1) NOT NULL, [MA2111Mathematics1] [char](1) NOT NULL, [PH2111Engineeringphysics1] [char](1) NOT NULL, [CY2111Engineeringchemistry1] [char](1) NOT NULL, [GE2111Engineeringgraphics] [char](1) NOT NULL, [GE2112Fundamentalsofcomputingandprogramming] [char](1) NOT NULL, [GE2115Computerpracticelaboratory1] [char](1) NOT NULL, [GE2116Engineeringpracticelaboratory1] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester2") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER2]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [HS2161Technicalenglish2] [char](1) NOT NULL, [MA2161Mathematics2] [char](1) NOT NULL, [PH2161Engineeringphysics2] [char](1) NOT NULL, [CY2161Engineeringchemistry2] [char](1) NOT NULL, [EC2151Electriccircuitsandelectrondevices] [char](1) NOT NULL, [GE2152Basiccivilandmechanicalengineering] [char](1) NOT NULL, [GE2155Computerpracticelaboratory2] [char](1) NOT NULL, [GS2165Engineeringpracticelaboratory1] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester3") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER3]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [MA2211Transformsandpartialdifferentialeqations] [char](1) NOT NULL, [CS2203Objectorientedprogramming] [char](1) NOT NULL, [CS2202Digitalprinciplesandsystemdesign] [char](1) NOT NULL, [IT2201Datastructuresandalgorithm] [char](1) NOT NULL, [IT2202Principlesofcommunication] [char](1) NOT NULL, [GE2021Environmentalscienceandengineering] [char](1) NOT NULL, [CS2207Digitallab] [char](1) NOT NULL, [IT2205Datastructuresandalgorithmlab] [char](1) NOT NULL, [CS2209Objectorientedprogramminglab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester4") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER4]( [Registerationnumber] [numeric](11, 0) NULL, [Studentname] [nchar](20) NULL, [MA2262Probilityandqueuingtheory] [char](1) NOT NULL, [CS2255Databasemanagementandsystems] [char](1) NOT NULL, [CS2252Microprocessorandmicrocontrollers] [char](1) NOT NULL, [CS2253Computerorganisationandarchitecture] [char](1) NOT NULL, [CS2254Operatingsystems] [char](1) NOT NULL, [IT2251Softwareengineeringandqualityassurance] [char](1) NOT NULL, [CS2258Databasemanagementandsystemslab] [char](1) NOT NULL, [CS2257Operatingsystemslab] [char](1) NOT NULL, [CS2259Microprocessorlab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester5") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER5]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [IT2301Javaprogramming] [char](1) NOT NULL, [MG2452Engineeringeconomicsandfinancialaccounting] [char](1) NOT NULL, [CS2304Systemsoftware] [char](1) NOT NULL, [CS2302Computernetworks] [char](1) NOT NULL, [CS2403Digigtalsignalprocessing] [char](1) NOT NULL, [IT2302Informationtheroyandcoding] [char](1) NOT NULL, [CS2308Systemsoftwarelab] [char](1) NOT NULL, [IT2305Javaprogramminglab] [char](1) NOT NULL, [GE2321Communicationskillslab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester6") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER6]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [IT2351Networkprogrammingandmanagement] [char](1) NOT NULL, [CS2353Objectorientedanalysisanddesign] [char](1) NOT NULL, [IT2352Cryptographyandnetworksecurity] [char](1) NOT NULL, [IT2353Webtechnology] [char](1) NOT NULL, [IT2354Embeddedsystems] [char](1) NOT NULL, [Elective] [char](1) NOT NULL, [IT2357Webtechnologylab] [char](1) NOT NULL, [CS2357Objectorientedanalysisanddesignlab] [char](1) NOT NULL, [CS2307Networklab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester7") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER7]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [IT2401Serviceorientedarchitecture] [char](1) NOT NULL, [IT2402Mobilecommunication] [char] (1) NOT NULL, [CS2401Computergraphics] [char](1) NOT NULL, [IT2403Softwareprojectmanagement] [char](1) NOT NULL, [Elective2] [char](1) NOT NULL, [Elective3] [char](1) NOT NULL, [IT2406Serviceorientedarchitecturelab] [char](1) NOT NULL, [CS2405Computergraphicslab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester8") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER8]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [Elective4] [char](1) NOT NULL, [Elective5] [char](1) NOT NULL, [IT2451Projectwork] [char] (1) NOT NULL)", con); com.ExecuteNonQuery(); } con.Close(); Label2.Text = "you successfully created a database table '" + DropDownList1.SelectedValue + "' in batch '" + DropDownList2.SelectedValue + "' "; } } }
sarathbabu12
Member
14 Points
12 Posts
Re: error in creating a table dynamically
Feb 21, 2012 05:50 PM|LINK
see creating r typing such a big query is im possible,, so only i just copied from the query windowwwwww
Paul Linton
Star
13431 Points
2535 Posts
Re: error in creating a table dynamically
Feb 22, 2012 05:54 AM|LINK
You are missing a ) at the end of the statement.
Notice that you have a ( at the start of the list of columns but no matching ) at the end.
bbcompent1
All-Star
33063 Points
8516 Posts
Moderator
Re: error in creating a table dynamically
Feb 22, 2012 11:01 AM|LINK
Here is the code with the correction to the missing parenthesis.
namespace Waafe_version_1._0 { public partial class adminaddsemester : System.Web.UI.Page { private List<String> year = new List<String>(); private List<String> semester = new List<String>(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownList2.DataSource = GetYears(); DropDownList2.DataBind(); DropDownList1.DataSource = Getsemester(); DropDownList1.DataBind(); } } public List<String> GetYears() { string startingYear = "2000"; DateTime startYear = Convert.ToDateTime("01/01/" + startingYear); for (int i = 0; i < 20; i++) { int year1 = startYear.AddYears(i).Year; int year2 = startYear.AddYears(i + 4).Year; String yearfinal = year1.ToString() + year2.ToString(); year.Add(yearfinal); } return year; } public List<String> Getsemester() { for (int i = 1; i < 9; i++) { string year1 = "semester" + i; semester.Add(year1); } return semester; } protected void LinkButton1_Click(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=SARATH-31201114\\SQLEXPRESS;Initial Catalog='" + DropDownList2.SelectedValue + "' ;User ID=sa;Password=T0Ge+Da+a"); con.Open(); if (DropDownList1.SelectedValue == "semester1") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER1]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [HS2111Technicalenglish1] [char](1) NOT NULL, [MA2111Mathematics1] [char](1) NOT NULL, [PH2111Engineeringphysics1] [char](1) NOT NULL, [CY2111Engineeringchemistry1] [char](1) NOT NULL, [GE2111Engineeringgraphics] [char](1) NOT NULL, [GE2112Fundamentalsofcomputingandprogramming] [char](1) NOT NULL, [GE2115Computerpracticelaboratory1] [char](1) NOT NULL, [GE2116Engineeringpracticelaboratory1] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester2") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER2]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [HS2161Technicalenglish2] [char](1) NOT NULL, [MA2161Mathematics2] [char](1) NOT NULL, [PH2161Engineeringphysics2] [char](1) NOT NULL, [CY2161Engineeringchemistry2] [char](1) NOT NULL, [EC2151Electriccircuitsandelectrondevices] [char](1) NOT NULL, [GE2152Basiccivilandmechanicalengineering] [char](1) NOT NULL, [GE2155Computerpracticelaboratory2] [char](1) NOT NULL, [GS2165Engineeringpracticelaboratory1] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester3") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER3]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [MA2211Transformsandpartialdifferentialeqations] [char](1) NOT NULL, [CS2203Objectorientedprogramming] [char](1) NOT NULL, [CS2202Digitalprinciplesandsystemdesign] [char](1) NOT NULL, [IT2201Datastructuresandalgorithm] [char](1) NOT NULL, [IT2202Principlesofcommunication] [char](1) NOT NULL, [GE2021Environmentalscienceandengineering] [char](1) NOT NULL, [CS2207Digitallab] [char](1) NOT NULL, [IT2205Datastructuresandalgorithmlab] [char](1) NOT NULL, [CS2209Objectorientedprogramminglab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester4") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER4]( [Registerationnumber] [numeric](11, 0) NULL, [Studentname] [nchar](20) NULL, [MA2262Probilityandqueuingtheory] [char](1) NOT NULL, [CS2255Databasemanagementandsystems] [char](1) NOT NULL, [CS2252Microprocessorandmicrocontrollers] [char](1) NOT NULL, [CS2253Computerorganisationandarchitecture] [char](1) NOT NULL, [CS2254Operatingsystems] [char](1) NOT NULL, [IT2251Softwareengineeringandqualityassurance] [char](1) NOT NULL, [CS2258Databasemanagementandsystemslab] [char](1) NOT NULL, [CS2257Operatingsystemslab] [char](1) NOT NULL, [CS2259Microprocessorlab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester5") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER5]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [IT2301Javaprogramming] [char](1) NOT NULL, [MG2452Engineeringeconomicsandfinancialaccounting] [char](1) NOT NULL, [CS2304Systemsoftware] [char](1) NOT NULL, [CS2302Computernetworks] [char](1) NOT NULL, [CS2403Digigtalsignalprocessing] [char](1) NOT NULL, [IT2302Informationtheroyandcoding] [char](1) NOT NULL, [CS2308Systemsoftwarelab] [char](1) NOT NULL, [IT2305Javaprogramminglab] [char](1) NOT NULL, [GE2321Communicationskillslab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester6") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER6]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [IT2351Networkprogrammingandmanagement] [char](1) NOT NULL, [CS2353Objectorientedanalysisanddesign] [char](1) NOT NULL, [IT2352Cryptographyandnetworksecurity] [char](1) NOT NULL, [IT2353Webtechnology] [char](1) NOT NULL, [IT2354Embeddedsystems] [char](1) NOT NULL, [Elective] [char](1) NOT NULL, [IT2357Webtechnologylab] [char](1) NOT NULL, [CS2357Objectorientedanalysisanddesignlab] [char](1) NOT NULL, [CS2307Networklab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester7") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER7]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [IT2401Serviceorientedarchitecture] [char](1) NOT NULL, [IT2402Mobilecommunication] [char] (1) NOT NULL, [CS2401Computergraphics] [char](1) NOT NULL, [IT2403Softwareprojectmanagement] [char](1) NOT NULL, [Elective2] [char](1) NOT NULL, [Elective3] [char](1) NOT NULL, [IT2406Serviceorientedarchitecturelab] [char](1) NOT NULL, [CS2405Computergraphicslab] [char](1) NOT NULL)", con); com.ExecuteNonQuery(); } else if (DropDownList1.SelectedValue == "semester8") { SqlCommand com = new SqlCommand("CREATE TABLE [dbo].[SEMESTER8]( [Registerationnumber] [numeric](11, 0) NOT NULL, [Studentname] [char](50) NOT NULL, [Elective4] [char](1) NOT NULL, [Elective5] [char](1) NOT NULL, [IT2451Projectwork] [char] (1) NOT NULL)", con); com.ExecuteNonQuery(); } con.Close(); Label2.Text = "you successfully created a database table '" + DropDownList1.SelectedValue + "' in batch '" + DropDownList2.SelectedValue + "' "; } } }