Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.††Topics such as question regarding the System.Data namespace are appropriate.††Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 1st, 2003, 09:47 AM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Incorrect syntax near '.'

Hi Guys,

I am tyring to updata the database form a webform but i get the error "Incorrect syntax near '.'",here is the code I am using.

void store(Object Sender,EventArgs e)
{

  SqlCommand objCommand;
  string strSql;
  strSql=" insert into Login values (Convert.ToString(Text1.Value), Convert.ToString(Text2.Value) ) ";
  objCommand =new SqlCommand(strSql,objConnection);
  objCommand.ExecuteNonQuery();
  }
I get the error on the last line and text1 is of type text nd text 2 is of type password.

Any tips??

Reply With Quote
  #2 (permalink)  
Old December 1st, 2003, 10:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

At the moment you are sending "insert into Login values (Convert.ToString(Text1.Value), Convert.ToString(Text2.Value) )" to your databse, but your database won't know what "Convert.ToString(Text1.Value)" means. You need to send the result of "Convert.ToString(Text1.Value)" to your database instead. Like this:
Code:
strSql="insert into Login values ('" + Convert.ToString(Text1.Value) + "', '" + Convert.ToString(Text2.Value) + "' )";
Then you will end up with a statement like
"insert into Login values ('abc', 'xyz')" which your database will understand.
Reply With Quote
  #3 (permalink)  
Old April 17th, 2010, 08:37 AM
Registered User
 
Join Date: Apr 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Incorrect syntax near 'DOT_NET'.

public void show()
{
da = new SqlDataAdapter("select * from'"+Session["table"].ToString()+"'", cn);
ds = new DataSet();
da.Fill(ds,"tmp");
GridView1.DataSource = ds;
GridView1.DataBind();
}
in this code in table three temporary values are coming DOT_NET,JAVA,LINUX but showing the same error respectively..
kindly give solution
Reply With Quote
  #4 (permalink)  
Old June 2nd, 2010, 01:04 AM
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Incorrect syntax near '-'

use AOTGL
declare @cStatement varchar(255)
declare G_cursor CURSOR for select 'grant select,update,insert,delete on '+ convert(varchar(64),name) + ' to DYNGRP' from sysobjects
where type = 'U' or type = 'V'
and name like 'Report%'
set nocount on
OPEN G_cursor
FETCH NEXT FROM G_cursor INTO @cStatement
WHILE (@@FETCH_STATUS <> -1)
begin
EXEC (@cStatement)
FETCH NEXT FROM G_cursor INTO @cStatement
end
DEALLOCATE G_cursor

Please help me out i am getting below error for this query:
Incorrect syntax near '-'
Reply With Quote
  #5 (permalink)  
Old June 7th, 2010, 12:29 PM
Authorized User
 
Join Date: Nov 2009
Location: Portsmouth,NH
Posts: 22
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via Yahoo to msherburne84
Default

I know this may sound silly but try this:

Code:
WHILE (@@FETCH_STATUS = 0)
begin
 EXEC (@cStatement)
 FETCH NEXT FROM G_cursor INTO @cStatement
end
or

Code:
WHILE (@@FETCH_STATUS != -1)
 begin
  EXEC (@cStatement)
  FETCH NEXT FROM G_cursor INTO @cStatement
 end

its worth a try, I don't see why your example wouldn't work
Reply With Quote
  #6 (permalink)  
Old July 5th, 2010, 01:32 PM
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Incorrect syntax near '-'

Issue resolved.......chk out the KB#872246 in MBS
Reply With Quote
  #7 (permalink)  
Old February 27th, 2012, 12:01 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datalist Paging

Hi..

I am getting this Error for the below query as i am using it in my Server side code ,Plz do find the solution Thanks in advance...

SqlDataAdapter objSQLAdapter = new SqlDataAdapter("select * from (select *,ROW_NUMBER() OVER(ORDER BY eno DESC) AS RowNumber from dtable)", myConnection); objSQLAdapter.Fill(DS, "Student1");

Error is :Incorrect syntax near ')'.
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Incorrect syntax near 'FULLTEXT'? Ron Howerton SQL Server 2005 5 August 30th, 2006 03:39 PM
Incorrect syntax near '!' sinapra Classic ASP Databases 8 August 25th, 2004 02:15 AM
Incorrect syntax near '`' Hez Classic ASP Databases 3 August 5th, 2004 08:13 AM
Incorrect syntax...... Adam H-W Classic ASP Databases 8 June 21st, 2004 11:14 AM
Incorrect SQL Syntax??! ckudrna Access ASP 1 June 5th, 2003 01:37 PM



All times are GMT -4. The time now is 11:52 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.