|
Hi
i want to know how to do a "select distict" on multiple field.
for example suppuse we have a table with field FirstName and LastName.
and we want to select all distinct the people in this table with a Query with distinct FName and LName.
I know i can use other elegant ways (such as relationship) to do so, but i need to know that query.
thanks
|
|
|
|
|
Distinct keyword is associated with one row, not with one column. So you can't get distinct rows on the base of two columns.
Sushant Duggal.
|
|
|
|
|
Hello,
Did u try group by clause? If not then u may write in the following way to get the distinct value.
SELECT FName,LName
FROM YourTableName
group by FName,LName
Mehedi Hasan
|
|
|
|
|
I was talking about the distinct keyword.
Perhaps, thanks for the query.
Regards,
Sushant Duggal.
|
|
|
|
|
Does data repeats multiple times in fields FName and LName?
If so then you can use distinct otherwise try to group, if this doesn't works explain more your question.
|
|
|
|
|
Hi friends,
I am getting a strange error. I am working on .NET framework 1.1.
When I work on a desktop application(C#.NET) and try to connect to SQL Server 2000 through my application, everything works fine and the connection is successfully established.
But when I use the same database in web project(ASP.NET/C#), I am unable to connect to the database.
I get an error:
"SQL Server does not exists or access denied".
I have carefully checked the connection string and everything in the code if perfect.
Please help me out.
Regards,
Sushant Duggal.
|
|
|
|
|
Paste your connection string here
There may be some errors
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
Hi
I am using the same connection string for two projects.
One is desktop application and other is web application.
Desktop application is working fine, database connectivity is fine whereas I am unable to connect in web application.
Still I am writing the connection string for ur reference.
user id=sa;password=XXX;data source=XXX;initial catalog=XXX
Sushant Duggal.
|
|
|
|
|
data source=XXX ? is it your local machine?
What is the OS for database server ?
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
No data source is not on my machine. I am working in a network.
It was working fine 1 month ago. From last month I was working on a desktopn application. But now I opened my previous project (web project) ans I discovered the error.
Sushant Duggal.
|
|
|
|
|
I dont have anything more to suggest. Anyhow Please visit this link and try to solve your problem
http://support.microsoft.com/kb/328306[^]
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
Thanks for your effort Sylvester
Regards,
Sushant Duggal.
|
|
|
|
|
Below is the correct syntax for both Web.config and Code Behind files.
Web.config:
-------------------------------------------------------------------<configuration>
<appsettings>
<add key="ConnectionString1" value="Server=ServerNameHere;User Id=UserNameHere;password=PasswordHere;database=DatabaseNameHere">
-------------------------------------------------------------------
Code Behind in your Application (C# example):
-------------------------------------------------------------------
using System.Data.SqlClient;
using System.Configuration;
namespace YourNameSpaceHere
{
public class YourWebPageNameHere : System.Web.UI.Page
{
public string strConnString1
private void Page_Load(object sender, System.EventArgs e)
{
strConnString1 = ConfigurationSettings.AppSettings["ConnectionString1"];
{
}
}
-------------------------------------------------------------------
NOTE:
Now you are able to reference this connection string throughout your code.
Let me know if this helps,
Aaron S.
Power Base Media
|
|
|
|
|
Sushant Duggal wrote: Hi friends,
I am getting a strange error. I am working on .NET framework 1.1.
When I work on a desktop application(C#.NET) and try to connect to SQL Server 2000 through my application, everything works fine and the connection is successfully established.
But when I use the same database in web project(ASP.NET/C#), I am unable to connect to the database.
I get an error:
"SQL Server does not exists or access denied".
I have carefully checked the connection string and everything in the code if perfect.
Please help me out.
Are you using Windows Authentication or SQL authentication
If you are using Windows auth, ASP.NET runs under an ASP.NET user and so that user needs to have permissions to your database.
|
|
|
|
|
Hi,
I am using SQL authentication.
I am using the same connection string for two projects.
One is desktop application and other is web application.
Desktop application is working fine, database connectivity is fine whereas I am unable to connect in web application.
Still I am writing the connection string for ur reference.
user id=sa;password=XXX;data source=XXX;initial catalog=XXX
Regards,
Sushant Duggal.
|
|
|
|
|
This is not an answer to your question, but rather a general comment. It is a bad idea to use the sa account as a general purpose access account. This account has special privileges which means that it can access and do things in your database that you really don't want to let outside users get access to.
There is a security principle about reducing the attack surface which applies here. If you only want the login to be able to access stored procedures and perform C RUD functions, then you really should create a dedicated account for it and use this in the connection string instead.
Sorry that I haven't answered your question, but I hope that this can help to remove what could end up being a security hole.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello
I am writing an application that should export some data from an SQL server 2005 server to an SQL Mobile (sdf file) on an remote PC.
What is the best way of doing this?
I want the user to be abel to choose witch data that should be exportet. So it is not allways the complete database that will be exportet
The user will then modify the data on the remote PC, and the idee is that he/she then could "import" the data, with some merge (conflict solving) solution. Any idees on how to solve this is appreciated.
Cheers
Spaz
|
|
|
|
|
Hi everyone.
pls help,I am busy with the security access system which monitores arrival ,lunch and depature time,so I need to calculate the time length
eg my table looks like this:
Date Name TimeIN TimeOUT Length
12/2/2007 Myself 7:45 12:00 4:55
so how do I calculate that 4:55 which is the difference of TImeIN and TimeOUT,I need a sql statement or any calculation methods to do that.
Thanks in advance.
|
|
|
|
|
Hope this helps
DECLARE @dd AS datetime<br />
SET @dd =(SELECT convert(datetime,TimeOUT) - convert(datetime,TimeIN))<br />
<br />
SELECT convert(varchar,@dd,108) AS minutes
|
|
|
|
|
thanks,but is still not working because the datatype of TimeIN and TimeOUT is Nvarchar not datetime,I did that because I wanted to insert them as DateTime.Now.ToShortDateString();so how will I manage to get the difference of nvarchar datype fields.
help....
|
|
|
|
|
try converting fields TimeOUT and TimeIN in varchar datatype.
DECLARE @dd AS datetime<br />
SET @dd =(SELECT convert(datetime,cast(TimeOUT as varchar)) - convert(datetime,cast(TimeIN as varchar)))<br />
<br />
SELECT convert(varchar,@dd,108) AS minutes
|
|
|
|
|
you can use the datediff function to dothis!
first, get the differnce in hrs and then find the difference in minutes....
Gautham
|
|
|
|
|
Hi every body.
i want to have a query in sql server 2000 which loads the sets of number less than 100. what should i do?
SELECT ? [WHERE]?
Thanks
Rastgar
|
|
|
|
|
m.rastgar wrote: i want to have a query in sql server 2000 which loads the sets of number less than 100. what should i do?
SELECT ? [WHERE]?
If you are storing numbers in a column called "MyNumbers" in a table called
"MyTable" , then to get all numbers less than 100 you can do:
SELECT MyNumbers FROM MyTable WHERE MyNumbers <100
Here is a good place to start leaning SQL[^]
|
|
|
|
|
Hi ..
I'm using Vb.net 2000 and Sql Server 2000 .. and I'm using the next code to connect with database ..
Public SqlCon As SqlConnection = New SqlConnection("workstation id=DESKTOP;Password=123; packet size=4096;user id=sa;integrated security=SSPI;data source=ComputerName;persist security info=False;initial catalog=Data")
I prepare a server and the network is allready work , and the dotnet framework 2 is installed on all pc on ... and every thing is good , when I run the program on anohter pc on the net work the next message error is appearing...
Could not load file or Assembly ( ADODB, Version=7.0.3300.0, Culture=neutral , Publickey token = bo3f5711d5.a3a) or one of its dependencies . The system can nptfind the file specified
can any one help me
jooooo
-- modified at 3:26 Monday 12th February, 2007
|
|
|
|