IT Community - Software Programming, Web Development and Technical Support

SQLError

This is a discussion on SQLError within the ASP and ASP.NET Programming forums, part of the Web Development category; I tried to insert a value in a sql database through ASP.NET(C#). There is no error. But while ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 05:36 AM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Unhappy SQLError

I tried to insert a value in a sql database through ASP.NET(C#).

There is no error. But while executing the application a error occurs on the ExecuteNonQuery() statement.

The error is : Incorrect syntax near '12'

The source code is :


public void addproject(int bid)
{
try{
DateTime schedule;
int project_id,budget;
string title, desc, type, priority, remarks;
SqlDataAdapter sqladapter = new SqlDataAdapter("select * from project_details", sqlcon);
sqladapter.Fill(ds, "project_details");
project_id = ds.Tables[0].Rows.Count;
project_id += 1;
title = add_title.Text;
desc = add_description.Text;
budget = int.Parse(add_budget.Text);
schedule = DateTime.Parse(add_schedule.Text);
type = add_type.Text;
priority = add_priority.Text;
remarks = add_remarks.Text;

SqlCommand cmd = new SqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "INSERT into project_details (Project_id,Title,Description,Building_ID,Outline_ budget,Outline_schedule,Type,Priority,Remarks) VALUES (" + project_id + ",'" + title + "','" + desc + "'," + bid + "," + budget + "," + schedule + ",'" + type + "','" + priority + "','" + remarks + "')";
cmd.Connection = sqlcon;
sqlcon.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex) { Response.Write(ex.Message); }

}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-18-2008, 07:15 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 882
kingmaker is on a distinguished road
Send a message via Yahoo to kingmaker
Default Re: SQLError

check the insert statement in debug mode...get the sql from commandtext property and run it in SQL Server ...
__________________
The KINGMAKER
Makes Every Thing Possible

Stuffs (My Blog)
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-18-2008, 10:30 PM
Kirubhananth Kirubhananth is offline
D-Web Programmer
 
Join Date: Feb 2008
Location: My native is Madurai but now in Chennai
Posts: 61
Kirubhananth is on a distinguished road
Send a message via AIM to Kirubhananth Send a message via Skype™ to Kirubhananth
Smile Re: SQLError

Thank you brother. I found the mistake. Thank you for your reply.
-Kirubha
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 06:40 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0