SQL Syntaxual problem Native Mysql user

hello guys

i am  trying to execte a more advanced SQL statment then i have been previusly doing but it dosent seem to understand it, am i lacking in knowledge about somthing ?
it dosent understand the LIMIT or do anything about the ran()

sqlCmd.CommandText = "" +
"SELECT question " +
"FROM questions " +
"WHERE test_id='" + Request.QueryString["id"] + "' "+
"LIMIT 1 " +

it dosent understand the LIMIT or do anything about the ran()

7/9/2007 5:49:30 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 21


Limit is same a Top and rand is equivalent to newid(). So write in following way, 

sqlCmd.CommandText = "" + "SELECT TOP 1 question " + "FROM questions " + "WHERE test_id='" + Request.QueryString["id"] + "' "+ "ORDER BY newid() ";

Mehedi Hasan

Mark as answer if the post meets your requirement!
7/9/2007 7:11:56 AM

hi thanks

 i am new to MS SQL advanced syntax, i need to set a paramiter and somhow tell it not to select the same question next time


sqlCmd.CommandText = "" +
"SELECT TOP 1 question " +
"FROM questions " +
"WHERE test_id='" + Request.QueryString["id"] + "' "+ (Maybe here i can say AND NOT = @previousQuestion)
"ORDER BY newid() " +
"LIMIT 1 " +


how do i set @previousQuestion to the id of the question i just selected at the end of teh statment

any help i am stuck here



7/9/2007 5:48:21 PM

will i have to use a stored proceedure and set variables with if elses and stuff ? or is there an easier way ?

7/9/2007 5:50:36 PM

SELECT TOP 10 productName FROM products ORDER BY NEWID()

SELECT TOP 10 ProductName, RAND() as RandomValue FROM products ORDER BY 2


Choose the way u like ... they will return you the random value in ur case select the table and fields you want


Mark as answer if you think
this helped you Yes
7/9/2007 6:02:13 PM

Similar Artilces:

Problem with defaults and User defined datatype in SQL Server 2000 or SQL 7
why does powerdesigner create a default in the definition of a table like this (SQL 2000 or 7.5 don't allow it). I use PD7.5.0.826 create table dbo.STOCK ( STOCKID TStockId not null, Goods TGoods not null, Amount TAmount not null default 'create default D_TAmount as 0',, constraint PK_STOCK primary key (STOCKID) ) go Anybody got a clue to fix the definition file to use the correct syntax Found the problem, it was and error introduced after reading models created from ...

Converting a gridView using an Sql Datasource to a gridview who is not using an SQL DataSource
How can i rewrite this page so that i doesnt make use of an SqlDataSource?  <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginHistory.ascx.cs" Inherits="Private_UserControls_WebUserControl" %> <html> <head> <%--<link rel="stylesheet" href="BaldwinPortal.css" mce_href="BaldwinPortal.css" type="text/css" />--%> <title>Login History</title> </head> <body style="margin:0 0 0 0;padding:0 0 0 0"> ...

SQL Server 2005 Installation problems with SQL Server Express & SQL Server 2000
Hi Guys, I have had SQL Server Express and Sql Server Management Studio Express installed on my machine for some time and recently tried to install a trial of SQL Server 2005 as well.  (Yes, I'm migrating from Visual Studio Express to Visual Studio Professional, just as in tended!) Everything went fine except that nothing seemed to be installed.  I searched in all the obvious places - both on the Start/Programs menu and on the hard-drive: nothing. A check under Add/Remove Programs showed that Sql Server 2005 Express was installed, but called SQL Server 2005. So after a number o...

SQL Server Problem.(SQL-28000)
------=_NextPart_000_0033_01C12642.735DD1F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello, I'm a newbie here and have a question regarding the use of DBI::ODBC with SQL Server. I've checked the mail archives and seen others with the same problem but have yet to come across the solution. Here's what I'm doing: (note: actual user name and password have been changed here). use DBI; my %attr = ( PrintError => 1, RaiseError => 1 ); $dbh = DBI->connect("dbi:ODBC:LocalServer", &...

Problem in SQL Developing as restricted user (member of user group)
Greetings,VWD EE and other Tools do not have problems working O.K. on my machine, when I am logged-on as restricted(limited) user, both environment and local web server are functioning, and it was MS effort to do it right.BUT the Problem is, when I try to connect to database->new DB connection(either through vwd or management studio etc). I get an Error - which should be written to event log (according to msg) but it isn't - that I can't connect. I am sure that it is because NO SQL SERVER2005EXPRESS instance is running, which I think is the only prerequisite to have it work (I do not need...

Problems SQL Server -> SQL Anywhere
We have a strange problem when moving from MS SQL Server to SQL Anywhere. Can anyone help us with this problem Environment: Windows XP Sp1 Visual C++ 6.0 Adaptive Server Anywhere 8.0 ODBC driver Problem: I have derived a recordset class from CRecordset, and is using bulk row fetching. The data from the database is fetched in batches of 25 rows (default recordset size). If I terminate the operation when x rows are handled, the remaining (25-x) rows will turn up in the first batch when I restart the operation. All is well so far, but the first batch will hold ...

Problem Schema SQL (timetracker-add.sql)
Hi, I'm install the Time Tracker and need transfer the DataBase Sql 2005 Express to Sql 2000. In the file timetracker-add.sql don't have the all structre DB in this file, I'm not see the next tables: apnet_Applications, apnet_Membership, apnet_Roles, apnet_SchemaVersion, apnet_Users, apnet_UsersInRoles. I'm not understand, How create the schema? in the Sql 2005 Express don't have the "Generate SQL Scripts" for the "Enterprise Manager" Help Meeeeeeeeeeeeeeeee!  (Im have 3 day's in this problem) Cristobal Sanchez The asp tables and store...

Transact-SQL vs ANSI SQL problem
Hi all, I have transact sql statement: select pf.productfamilyid,ltrim(rtrim(pf.productfamilydesc)) as productfamilydesc, max(isnull(vp.productid,0)) as reported from productfamily pf,product p,visitproduct vp where pf.productfamilyid=p.productfamilyid and p.productid*=vp.productid and vp.customerid=81310471 and vp.marketcompanyid=1 and vp.visitdate='2004-10-11' group by pf.productfamilyid,productfamilydesc order by ltrim(rtrim(pf.productfamilydesc)) which I believe may be rewritten in ANSI SQL as: select pf.productfamilyid,ltrim(rtrim(pf.productfamilydesc)) as prod...

Sql 2005 and Sql Express connection problem
I have the following problem, and any help would be appreciated.  I am running sql 2005 on my production server, and developing websites on my development server running VWD and Sql Express.   I have been looking for the answer to this problem for about a week.  When I upload my site to the production server I get sql errors  on all the pages with dynamic content.  I have looked into the permissions but nothing is working.  Has someone had a similar problem and found a solution?   Thanks for any help. What's the error message?Welcome to my SQL/ASPNET...

Sql, Sql express, Access or mysql for data
If this has been discussed before i apologise as i am fairly new to the asp forum and was not sure where to search for threads. I am upgrading to a new web plan that supports asp and i noticed that godaddy supports all of the above databases.  I was curious if there are any advantages to using one db over the others as far as web is concerned?  What i am looking to do is handle guestbook,  logins for registered users which would control access to certain downloads and possibly pages as well.  And it was also advised that i look into using a database to store and d...

SQL Server Reporting Services for SQL SERVER 2000 AND Visual Studio.NET 2005 .NET 2.0
Hi, Which version of SQl Server Reporting Services will work with SQL SERVER 2000 in pararrel with ASP.NET 2.0 (.NET 2.0 framework)?  Thanks, Azam HighOnCodingWanna get high! Hi, Okay I got the answer. Yes, we can use the SQL SERVER 2005 Reporting Services with SQL SERVER 2000. HighOnCodingWanna get high! ...

[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
Hello All, I'm Getting the following error when calling a dll from my vb.net application. [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. The dll was written in vb6 and accesses a sql db using the following connection string. Public Const GLOBAL_DNS As String = "DSN=TransSrvFinal;UID=sa;PWD=admin;" This DLL works fine when called from other Windows Apps. However I'm now trying to call this dll from with in an asp.net application. I'm using vb.net as the codebehind. I'm a...

SQL A and SQL Server
Hi I heard SQL Server used to be owned by Watcom is this true? Is SQL Anywhere, therefore, similar to SQL Server? -- Regards, John Not quite true. SQL Anywhere was created by Watcom. SQLServer was created by Sybase, and Microsoft licensed the technology. So MSSQL and ASE have common roots, not SQLAnywhere. -- Paul Horan[TeamSybase] "John Kingan" <john.kingan@abibuildingdata.com> wrote in message news:40d82aa1$1@forums-1-dub... > Hi I heard SQL Server used to be owned by Watcom is this true? Is SQL > Anywhere, therefore, similar to SQL Ser...

Problems with Linked servers between sql 2000 and sql 2005
Dear all   I have created linked server object between a sql 2000 and sql 2005 database. i have the latest mdacs installed and all the services enabled on both sides. But when i try and run a sql statement on the sql 2000 side i get this error: [DBNETLIB][ConnectionOpen (PreLoginHandshake()).]General network error. Check your network documentation. If i try and run a swl statment on the sql server 2005 side the procedure works.  Has anyone experienced the same problem?Any advice?   Thank you so much for the help.   DanDan  Try  also posting to the SQ...

Web resources about - SQL Syntaxual problem Native Mysql user - asp.net.sql-datasource

Resources last updated: 12/23/2015 12:04:23 PM