Forums

ASP

This topic is locked

ASP.NET DataSet Query Help

Posted 09 Oct 2003 07:01:40
1
has voted
09 Oct 2003 07:01:40 fatih mira posted:
This is my dataset query that was generated by DWMX.

<MMataSet
id="DataSet1"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_eLISDbConnection" %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_DATABASETYPE_eLISDbConnection" %>'
CommandText='<%# "SELECT strStockCode, strShortName, strCompanyName FROM dbo.Company ORDER BY strCompanyName ASC" %>' PageSize="10"
></MMataSet>
&lt;MM<img src=../images/dmxzone/forum/icon_smile_tongue.gif border=0 align=middle>ageBind runat="server" PostBackBind="true" /&gt;

I want to customize the CommandText not to include the sql statement but a variable that contain the sql statement. For example :

if request.form("code" = ""
sqlstatement = "SELECT strStockCode, strShortName, strCompanyName FROM dbo.Company ORDER BY strCompanyName ASC"
else
sqlstatement = "SELECT strStockCode, strShortName, strCompanyName FROM dbo.Company WHERE strStockCode = '"+request.form("code"+"' ORDER BY strCompanyName ASC"
end if

Replies

Replied 13 Oct 2003 11:54:28
13 Oct 2003 11:54:28 andre maas replied:
Try this:

Put the commandtext in a variable

Dim sqlstatement

if request.form("code" = ""
sqlstatement = "SELECT strStockCode, strShortName, strCompanyName FROM dbo.Company ORDER BY strCompanyName ASC"
else
sqlstatement = "SELECT strStockCode, strShortName, strCompanyName FROM dbo.Company WHERE strStockCode = '"+request.form("code"+"' ORDER BY strCompanyName ASC"
end if

then in de MM-code:
CommandText= sqlstatement

Succes


Reply to this topic