VS 2010 - Passing Value To SQL Where Like Clause

Jul 25, 2011

I'm trying to pass the value string.empty to a parameter for a repeater but it does not work, here is code:

Code:
protected void Page_Load(object sender, EventArgs e)
{
EnableViewState = false;
string fromdate = (string)Session["thefromdate"];
string todate = (string)Session["thetodate"];
if ((string)Session["selectedserver"] == "All Servers")

[Code] ....

Thats the gyst of the onload code that deals with my session parameters, as you can see if the session parameter is passed "all servers" it sets the lable value to string.empty (have also tried seting it to "")

Code:
asp:Repeater ID="Repeater1" runat="server" DataSourceID="reoeaterappresuts">
<itemtemplate>
<b><u>Servername:</u>      <%# DataBinder.Eval(Container.DataItem, "Servername") %>      
<u>Date of check:</u>      <%# DataBinder.Eval(Container.DataItem, "Checkdate") %>      
<a href="/appdrilldown.aspx?entryid=<%# DataBinder.Eval(Container.DataItem, "EntryID") %>">

[Code] ....

And the front end repeater stuff, Why can i not pass across "where x like '%%'

It picks up the parameters from the labels on the page set onload....

View 4 Replies


Similar Messages:

Passing Parameters Using Stored Procedure With "where" Clause?

Apr 6, 2010

i have created this function with a parameter offset and i want to access the database using stored procedure but the code and stored procedure i have written below is not working...what is the right way to do it??

public bool isoffsetexist(int offset)
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_offset1";
SqlDataReader dr = cmd.ExecuteReader();
int i = 0;
while (dr.Read())
{
i++;
}
if (i == 1)
{
conn.Close();
return true;
}
else
{
conn.Close();
return false;
}
}

my stored procedure "sp_offset1" is

CREATE PROCEDURE [dbo].[sp_offset1]
@offset numeric,
@appname varchar(20),
@os varchar(20)
AS
select * from tb_offset
where @offset=" + offset + "

View 2 Replies

VS 2010 - Passing User Session To Another Website?

Dec 18, 2010

I have two websites both of which will share the same users in a SQL DB for membership. The first site is the standard site while the other is a subdomain for admins.

If the admin logs onto the either site, I don't want that person to have to re log on to either site if he/she is sent there via navigation. To the user it would just seem like one site. Because user would be using same session, if they log off either site they would have to reauthenticate.

How would I go about passing this information?

View 1 Replies

VS 2010 - Passing Image Control To Function In A Class?

Oct 31, 2012

I wrote a function in code behind of the aspx file to get from an SQL database the imageurl and assign it to that image's URL. This works fine so I decided to move it to a class but now the imageurl does not exist because the passed image control is now refering to system.drawing.image not the web image.

Code:
Public Sub ShowCodeImages(sProdCode As String, ByRef imgCode As Control, sConnectionString As String)

Dim sSQL As String
Dim sqlDCStock As New SqlConnection
Dim sqlDAStock As SqlDataAdapter
Dim sqlDTStock As DataTable

[Code] .....

View 1 Replies

Visual Studio :: Passing Report Parameters To SubReport In 2010 RDLC?

Oct 25, 2010

I'm having some troubles defining and passing report parameters to subreports in VS 2010. In VS 2008 in the design view I was able to right click and define the report parameter and have it passed through.

In VS 2010 that prompt is missing. So my question is, how can I pass a value from a parent report to a subreport in VS 2010?

Additionally, this is what is shown in the Report Properties dialog inside of VS 2010:

For the time being I have defined the parameter in the subreport manually in the XML but I'm receiving an error from the main report when I attempt to pass a parameter of any type to the subreport.

The error is :

An error occurred during local report processing.
Value cannot be null. Parameter name: value
Where I do not have a parameter named value defined anywhere.

View 2 Replies

C# - How To Make The Clause Different

Aug 14, 2010

I have the following code:

CustomerService service;
public CustomerService Service
{
get
{
if (this.service == null)
{
this.service = new CustomerService();
}
return this.service;
}
}
public DataTable GetCustomers()
{
return this.Service.GetCustomers();
}

Now the question is: if I wrote the above method as follow (without "this"), it's giving me an error : instance is not reference to an object.

public DataTable GetCustomers()
{
return Service.GetCustomers(); // this will spell the error "instance is not reference to an object"
}

Does anyone know? also it only happens while running via IIS and not from casini web server (VS 2010).

View 4 Replies

ADO.NET :: Is It Possible To Use OFTYPE In Where Clause Of An Entitydatasource

Nov 30, 2010

is it possible to use OFTYPE in where clause of an entitydatasource? I mean something like this:

srcUsers.Where = "OFTYPE(Doctor)";

View 1 Replies

SQL Server :: Group By Clause In CTE?

Mar 30, 2011

I have a query with group-by clause. I want to use it in recusionCTE.How is it possible?I want to know the totalamount for each fname done through this query:select top 10 fname,SUM(totamt) as 'Total Amount' from tables_list group by fname order by 'Total Amount' descBut when any person logins he must be able to see this list for his own hierarchy down the line including himself.

View 2 Replies

ADO.NET :: Using Where Clause Before Select In LINQ?

Aug 26, 2010

why use where condition before select statement in LINQ

View 2 Replies

ADO.NET :: Convert The Where Clause To Linq?

Oct 22, 2010

how do you convert the WHERE clause of this statement to Linq ?

View 1 Replies

Web Forms :: How To Use Dynamically SQL Where Clause

Mar 22, 2010

how to use dynamically SQL Where Clause

[Code]....

View 3 Replies

ADO.NET :: How To UPDATE With Extraneous WHERE Clause

Jul 31, 2010

I'm working on an MVC 2 website, with LINQ. I have the following section to handle updating my Photo object.

[Code]....

In this case, only the field Title changes. But I'm wondering why the WHERE clause isnot simply WHERE PhotoId = @p0... because PhotoId is the primary key. Is there anything I need to do when mapping or something to get the WHERE clause that I expect?

View 4 Replies

Asp - Syntax Error In FROM Clause

Oct 18, 2010

I'm working on asp.net web application & for this use MS access for back end, My Query is given below which is successfully executed on MS Access but error on front end ("Syntax Error in FROM Clause")

select USER.EMPID as EMPID,USER.FULLNAME as FULLNAME,
USER.USERNAME as USERNAME,Employee.ROLEID,ROLE.ROLENAME AS ROLE
FROM USER
inner join employee on user.userid=employee.userid
inner join role on employee.roleid=role.roleid
WHERE USER.EMAIL='admin@itiersolutions.com'
AND USER.PASSWORD='cZdqAEeDV2EVzA1JNFJ6hQ=='
AND USER.STATUS='Enable'

View 4 Replies

C# - EntityDataSource - Where Clause From Different Table?

Nov 22, 2010

I am using EF 4 and EntityDataSource in a Page (WebForms).

This page contains a DropDownList that display UserName.
Data from this DropDownList it is from "aspnet_Users".
At the moment I am using a single EntityDataSource code belove:
<asp:EntityDataSource ID="EntityDataSourceListUsers" runat="server" ConnectionString="name=CmsConnectionStringEntityDataModel"
DefaultContainerName="CmsConnectionStringEntityDataModel" EnableFlattening="False"
EntitySetName="aspnet_Users" Select="it.[UserId], it.[UserName]">
</asp:EntityDataSource>

I need to FILTER the UserName associated to a specific ROLE and displaying it in the DropDownList therefore using others tables"aspnet_UsersInRoles" and "aspnet_Roles".

How to do it?
Would be great have a simple solution since I am a beginner.

View 1 Replies

Using An IN Clause In Vb.net To Save Something To The Database Using SQL?

Sep 30, 2010

I have a textbox and a button on a form.

I wish to run a query (in Vb.Net) that will produce a query with the IN Values.

Below is an example of my code

myConnection = New SqlConnection("Data Source=sqldb;Initial Catalog=Rec;Integrated Security=True")
myConnection.Open()
myCommand = New SqlCommand("UPDATE dbo.Recordings SET Status = 0 where RecID in ('" & txtRecID.Text & "') ", myConnection)
ra = myCommand.ExecuteNonQuery()
myConnection.Close()
MsgBox("Done!", _
MsgBoxStyle.Information, "Done")

When i enter a single value it works but when i enter values with commas it throws an error
"Conversion failed when converting the varchar value '1234,4567' to data type int."

View 2 Replies

Function And Variable Declaration Without An 'As' Clause?

Aug 25, 2010

I get a message - "Function without an 'As' clause" for HMAC_MD5 and "Variable declaration without an 'As' clause" for Key and Value. But the code works. But the messages still exists. Is there a way to fix this to avoid the messages?

[Code]....

View 4 Replies

ADO.NET :: Unable To Update Records Using IN Clause?

Sep 15, 2010

I've a common function as shown below:

[Code]....

[Code]....

When I want to update records in a table, I usually invoke as shwon below:

[Code]....

This code works fine. But when I'm trying to update multiple records using IN clause, it does not work. Can any one tell me how to do it using IN clause?

I need to update all vendors available in lstVendorId to status 4. I tried below but it does not work.

[Code]....

The above code does not throw any error but it does not update any records either.

View 1 Replies

SQL Server :: Select Statement With Where Clause?

Feb 14, 2011

I have a select statement:

cmd = new SqlCommand("select lab_key from tblorderwhere", connection);

I would like to add a where statement that pass variable to the select statement. How I can do this?

Where lab_key =ChargeFine( that is my variable)

View 2 Replies

ADO.NET :: Linq And Dynamic Where Clause With Wildcard?

Mar 25, 2011

Linq add wildcard in the where clause dynamically I have a query, i.e.

var query = from r in context.company .....

then have some business logic and based on the validation I want to add dynamically a where clause

if(a == "1")

query = query.Where(r=> r.Name = Fullname); //works!!

else if(a == "2)

query = query.Where SqlMethods.Like(r=> r.Name,"%"+Fullname+"%"); //fails to compile , the r.Name is not found..

View 3 Replies

SQL Server :: Description About Working Of OVER Clause

Jan 26, 2011

I have created the folowing stored procedure and it is working fine... I have used OVER clause in the query written in the WITH block. Can some body provide description about working of OVER clause and why I need to use it with the ROW_NUMBER() function.

CREATE PROCEDURE SelectOrder
@PageIndex INT,
@PageSize INT
AS
BEGIN
WITH Order AS
(
SELECT ROW_NUMBER() OVER (ORDER BY OrderId DESC)
AS Row, *
FROM Orders
)
SELECT *
FROM Order
WHERE Row between (@PageIndex - 1) * @PageSize + 1 and @PageIndex*@PageSize
END

View 2 Replies

SQL Server :: Case Statement In Where Clause?

Sep 13, 2010

i trying following query Select

View 4 Replies

DataSource Controls :: Using Varibale In The Where Clause?

Apr 21, 2010

I am having difficulties using a variable in the "where" clause:

declare @shift_started as datetime
set @shift_started = (SELECT *
FROM OPENQUERY(ADS_RGWP_SERVER, 'SELECT MAX(shift_started) as shift
FROM salestkt AS STK
WHERE NOT EXISTS(SELECT *
FROM SHFTDATE AS SD
WHERE SD.shift_started = STK.shift_started)'))
SELECT *
FROM OPENQUERY(ADS_RGWP_SERVER, ' sum(case when customer_type = ''Inter-Company'' then qty_shipped_today else 0 end) as intercompany_qty,
sum(case when customer_type = ''Charge'' then qty_shipped_today else 0 end) as outside_qty
FROM salestkt
WHERE shift_started ='" & @shift_started & "' ''')

Getting error:

Incorrect syntax near ' & @shift_started & '.

View 9 Replies

Linq To Entities Multiple - Clause &&

Feb 22, 2010

In the code bdehind && syntax does not work, any ideas?

Entities ctx3 = new Entities();
var uniqueQuote = from quot in ctx3.Quotes.Include("aspnet_Users").Include("Enquiries")
where quot.Enquiries.EnquiryId == selectedEnquiryId && [code]...

Error 2 Delegate 'System.Func' does not take '1' arguments C:LocalGarageFinderLocalGarageFinderEnquiryDetail.aspx.cs 56 33 LocalGarageFinder

View 1 Replies

DataSource Controls :: Add Parameter To IN Clause In SQL?

Jan 28, 2010

i am developing an application using asp.net and backend server is SQL SERVER 2005.

in my application i have 12 regions. from that 12 regions user will select any of them.

if user select 1,2,3 then i have to pass this string to IN clause

for that i have storedproc like

create procedure sp_updateDistributorContractforAllRegions (
@unitprice float,
@region varchar(50)
)
update employee set UnitPrice=@unitprice where regionid in (@region)
end
GO

here regionid datatype in employee table is INT.

from code behind i am adding the parameter as 1,2,3.when i run the query it gives the error as

Conversion failed when converting the varchar value '1,2,3' to data type int.

View 3 Replies

EntityDataSource Using IN Clause On Navigation Property Collection?

Feb 28, 2011

I'm using EntityDataSource to retrieve my items, and i want to get the items for a particular region. (items and regions has a many to many relationship, thus item has a regions navigation property). and I'm using "IN" to filter the items. tried several combinations and it kept on throwing various errors. how can i get this sorted out:

Below is My DataSource:

[code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved