Pass string parameter to SqlDataSource in asp.net - c#

i have placed a SqlDataSource component on my aspx page but while configuring the SqlDataSource in the "Test Query" Step I am passing the following parameters :
But when i click ok it returns following error:
This error occurs when i pass the string :
INFO, WARN, ERROR,
I have tried a lot of combinations but nothing works. It works only if i pass one of the three words in single quotes like this :
'ERROR'
Infact the INFO WARN and ERROR are the various levels available in the table. Each record can have only one level and in the sql query i am using IN("-----") to match the criteria, hope you understand.
Any idea to pass the string with comas between them will be highly appreciated.

After you create the page with the dialogue helpers, just switch to code view of your html and change them by hand on the created code...

I have resolved the problem by passing each level in single quotes without , after the last level as shown in the image below:
Anyway thanks for your help Aristos!

Related

Parameters not being passed correctly through code

My report gets data from a stored procedure. Two of the six parameters are dates (toDate and fromDate.) I integrate the report with C# Winforms and I pass the parameters through code the code with:
reportDocument.setParamterValue(0,paramValue);
The report works fine but does not render data despite showing the column header properly. When I refresh the report, it pops up the parameter window again. When I enter the parameters through that window the data shows, including column headers. But it doesn't work when I pass parameters through code.
How can I resolve this?
It looks like this:
CRPT.SetParameterValue("smonth", Servercls.month);
See this link for more info.
I suggest first of all call procedure in c# environment and save result in datatable and then send datatable to crystal report.
I found the error.
First it was not working with setting parameters through indexing. so i set the parameters through name as reds suggested.
second i was missing the parameters binding with report viewer object.
so i added the following line and it worked
crystalReportViewer.ParameterField.addRange(reportDocument.ParameterFields);
Thanks for the answers guys.

Retrieve Resource Values Programmatically in asp.net C#

I want to get strings from my App_resource programmatically because I get from the DB a keyword with the name of the string in the app_resource mlbRes.
I have a stored procedure that indicates what the user should do next, sending a string that corresponds to a string in my app_resources file. I can do it with a switch, but that will only complicate my code.
As you can see in the following screenshot, I've tried different approaches, but none worked so far.
screenshot
Can anyone point me out what I'm doing wrong?
Thanks in advance.
Use this Syntax Here mlbRes is your resource file name
string value= Resources.mlbRes.ResourceManager.GetString("StringName");

Parsing HTML Input to C# code on Page Load

I have a tricky question. Hope somebody can answer this for me.
I am using a Site based on DOtnetNuke CMS. I have a page which has an input field
<input name="ct100$dynamicinputfield1" id=ct100$dynamicinputfield1 value="abc">
This input field is auto generated and i cannot change the code for this.
Now i have another module which runs on Page_load
The module has A stored Procedure which expects an input parameter which is the value of the Input field mentioned above.
I supply the parameter to the code using this line
string Id = Request.Form["ctl00$dynamicinputfield1"];
I get the following Error
Error:System.Data.SqlClient.SqlException (0x80131904): Procedure or
function 'GetAddressByID' expects parameter '#ID', which was not
supplied.
I believe this happens because the Server side code executes before the client side. and thus the Request.form cannot find the dynamicinputfield1. How can i solve this Issue.
After posting the form from client side you must have to get this property value.
Before posting the form how can u get one.
second thing you must get the value of the item on server side before posting to client with the original name of the input field.
hope this answer helps.

how to view/display data from database using different parameter

Could you support me to display data from database using different parameter. Just try to explain I have
=> Five========= **From [] to []** and one another drop down.
=> I need to have accept all drop down values from the user and doing searching and displaying the result on the same page to searching interface. HOW CAN I DO THIS ?
PLEASE HELP ME and may I get source code please ?
Hi Have a look at stored Procedures -
call a stored procedure, and pass in the parameters to get the result.
http://technet.microsoft.com/en-us/library/aa174792(v=sql.80).aspx

Problem passing filename between pages (query string)

I've tried and tried but just cannot get a hold of this so let me explain my problem.I have a survey website using xml survey files. On one page I have a category menu which passes relative surveys filename to another page in the redirect as a query string.
~/websurvey.aspx?Survey=gamesurvey.xml
so the name of the survey file is gamesurvey.xml. On another page I have the following to read the filename into a string.
string c = Request.QueryString["Survey"];
now here lies my problem. The control that I have to pass the filename to does not recognise any attempts I make at trying to "dereference" the string. Here is the part in question.
<sstchur:WebSurvey id = "ws"
SurveyFile = "gamesurvey.xml"
AnswersFile = "answers.xml"
runat = "server"/>
</form>
Above where you see gamesurvey.xml thats where I need to pass the string. Here it is hardcoded.This is a problem because I want to be able to call any survey by way of query string without having to make new pages for each of them.
If I put things like
""+c+"" or .toString() or SurveyFile = c
it tells me the server tag is not well formed.
To sum up my problem I need to pass a filepath directly from page to page. By the way, when I put SurveyFile = c I get a pageload error saying the file c cannot be found, i.e. this control will only take a filename not a variable containing it.
Sorry if this is hard to understand but my head is just melted with it now I had to ask.
Any help would be appreciated.
The control im using is the WebSurvey control 4GuysFromRolla and yes I have checked all the documentation and the few forum posts related to it.
And what prevents you from setting that control property in your code-behind?
If you've your "page.aspx.cs", just do that in the Page.Init Page.Load event and you'll be fine!
Maybe I'm wrong and you can't use code-behind or something like that.
i am giving u few options
use
SurveyFile= <% c %>
or since you are not passing the full file path so ur file is not found. give it like ~//root//directory//filename.extension
or may be
u can find some methods to set that parameter using the code behind page.
do tick my answer correct if found useful

Categories

Resources