开发者

SQLite error: near "?": syntax error

开发者 https://www.devze.com 2022-12-28 04:54 出处:网络
I am getting error message \"near \"?\": syntax error\" randomly while executing the query \"SELECT [record] FROM [ac_contacts_cache] LIMIT 0,

I am getting error message "near "?": syntax error" randomly while executing the query "SELECT [record] FROM [ac_contacts_cache] LIMIT 0, 3".

Table schema:

开发者_如何转开发CREATE TABLE IF NOT EXISTS [ac_contacts_cache] ( [record] TEXT NOT NULL )

Any help here is appreciated.


I have been trying to get LIMIT to work in MS SQL with no luck. Is this a MySql Command?

Anyhow, try this.

SELECT TOP 3 [record] FROM [ac_contacts_cache]

Now for your create table. I have tested both code out just to make sure this works, and is working in SQL server and is basic sql so should be fine in SQL Lite.

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'TestTable') AND type in (N'U'))
CREATE TABLE [dbo].TestTable(
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [FirstName] [text] NOT NULL ,
    [LastName] [text] NOT NULL)

The first line, if you do a SELECT * FROM sys.objects, you can get a good idea of whats going on. Your simply just retrieving all of the tables on the system, and looking for the one your about to create (Specified in the Where clause, 'TestTable'). If its not created, we move on to our next statement, the Create Table.

You were pretty much dead on here. So I'm sure you can tell whats going on!

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号