473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

sqldatasource view sql statement

Hi.
Is there a way to view the SQL statement after the parameters have been replaced with their respective values.

ie. SELECT UserId, Firstname, Surname FROM tblStaff WHERE UserId = @LoginId

After setting @LoginId to 100
I want to be able to retrieve the modified statement that is passed to the Database - so it would return this

SELECT UserId, Firstname, Surname FROM tblStaff WHERE UserId = 100


I am using C# in the code behind - and this is where I want to access the sql.
Many thanks
Jul 11 '07 #1
3 1665
jhardman
3,406 Expert 2GB
bberry,

generally I do it like this:
Expand|Select|Wrap|Line Numbers
  1. response.write "<!-- query: " & query & " -->" & vbNewLine
"query" is of course the variable that I use to hold the sql query. I am using vbscript, I don't know how well this will translate to your system.

Jared
Jul 12 '07 #2
bberry,

generally I do it like this:
Expand|Select|Wrap|Line Numbers
  1. response.write "<!-- query: " & query & " -->" & vbNewLine
"query" is of course the variable that I use to hold the sql query. I am using vbscript, I don't know how well this will translate to your system.

Jared
Thanks Jared.

I am looking to extract the sql statement from the sqldatasource into a variable after the parameters have been entered, which I can then display.

Kind regards
bb
Jul 12 '07 #3
jhardman
3,406 Expert 2GB
bb,

Yeah, like I said. I generally do it like this:
Expand|Select|Wrap|Line Numbers
  1. dim query
  2. query = "SELECT * FROM "
  3. query = query & currentTable
  4. query = query & " WHERE "
  5. query = query & request.form("searchField")
  6. query = query & " = '"
  7. query = query & request.form("searchData")
  8. query = query & "' ORDER BY date"
  9.  
  10. response.write "<!-- query: " & query & " -->" & vbNewLine
  11.  
  12. objRS.open query, objConn, adOpenDynamic, adLockOptimistic
does this not answer your question?

Jared
Jul 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: aa | last post by:
I am using gridview and sqldatasource controls. When Gridview rows is creating I want to view the row's columns from database, which it is in select command in sqldatasource control, but not in...
8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
1
by: Henry Habermacher [MVP Access] | last post by:
Environment: VS2005, ASP.Net 2.0, SQLServer 2000, VB.Net, IIS6 I use a GridView Control which is based on a SQLDataSource. The datasource is based on a Select statement and is filtered by the...
3
by: Jim Andersen | last post by:
Just to let you know, and to help any future sorry sods who gets trapped in the same black hole...... You can't just copy/move a working sql-statement into a stored procedure. Working with a...
0
by: cyberbless | last post by:
I would like to dynamically assign a Select Statment to a a SqlDataSource. Problem is the SqlDataSource.Select() Command requires a "dataSourceSelectArgument" as one of its arguments. 1. What...
1
by: Jim McGivney | last post by:
I would like to return one specific value from an SQLDataSource configured to a table with an SQL Command selecting a specific value. It would be the equilivant of ExecuteScalar in OLEDB. Replies...
0
by: Sam | last post by:
Folks, I am new to ASP.Net 2.0. I do not know what I did with my configuration settings... Now when I drag and drop Sqldatasource from the toolbox, I can't see it in the design view. Even...
1
by: VB Programmer | last post by:
I have a SqlDataSource I setup on an ASP.NET 2.0 webform. I setup the SELECT statement and it has 1 parameter, @ProductId. How do I, using VB.NET, store the results of that SELECT statement...
2
by: Don Miller | last post by:
I have controls (dropdown list, radiobutton list) that are bound to an SQLDataSource. In the SELECT statement in the DataSource configuration I have tried to include other columns that would be...
0
by: ADAC | last post by:
I am very familiar with Visual studio 2003 and trying to get a handle on 2005 I can set up the datasource and make it work fine when I databind it to a control like a gridview or details view....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.