 |
| 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
|
|
|
|

December 1st, 2003, 10:47 AM
|
|
Registered User
|
|
Join Date: Dec 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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??
|
|

December 1st, 2003, 11:07 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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.
|
|

April 17th, 2010, 08:37 AM
|
|
Registered User
|
|
Join Date: Apr 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 2nd, 2010, 01:04 AM
|
|
Registered User
|
|
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 '-'
|
|

June 7th, 2010, 12:29 PM
|
|
Authorized User
|
|
Join Date: Nov 2009
Posts: 22
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
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
|
|

July 5th, 2010, 01:32 PM
|
|
Registered User
|
|
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Incorrect syntax near '-'
Issue resolved.......chk out the KB#872246 in MBS
|
|

February 27th, 2012, 01:01 AM
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ')'.
|
|
 |