Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2003, 10:47 AM
Registered User
 
Join Date: Dec 2003
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??

 
Old December 1st, 2003, 11:07 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
 
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
 
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 '-'
 
Old June 7th, 2010, 12:29 PM
Authorized User
 
Join Date: Nov 2009
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
 
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
 
Old February 27th, 2012, 01:01 AM
Registered User
 
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 ')'.





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.