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).
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.
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?
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'
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.
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."
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 "")
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?
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.
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
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 & "' ''')
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
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.
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:
I have an SqlDataSource query that should use an input parameter for multiple integer values, like:
select * from table1 where TableID IN (1,2,3,4,5)
->
select * from table1 where TableID IN (@IDValues)
How do I do that ? Default parameter settings won't work, returning "invalid integer value" . I suppose that parameter should be passed as some kind of array that SQL recognizes as multiple integer values , but what's the correct way of setting this ?