Pass UserName To The SQL Select ? (VB)

Jul 11, 2007

 

VB   ASP.NET 2.0 

How do I get the Authenticated UserName passed to a Select Command of a data control ?

I'm not clear on how to get the logged in username from User.Identity.Name as a string or how to pass it to the Select Command of a control.

I've had some success with SelectParameters / ControlParameter's in the Master Control context, but otherwise I don't understand how to create a Parameter for use with the SQL.

I want to show the user data from a database, based on who is logged in .

Help, greatly appreciated.

Chris

 

View 8 Replies


ADVERTISEMENT

Need To Pass 'UserName' To SQL Select WHERE Clause In The Data Source

May 30, 2007

Hi.I bet this is a 101 question, but i'd appreciate any help!I am in the 'where...' section of the configure data source wizzard .Column: I grab 'UserName' Operator: I select '='BUT how do I get the UserName (The user is signed into the app)  Is it from the Form? Profile? Session?Ive tried profile.name.....  THANKS In advance.... Dan 

View 4 Replies View Related

What Is The Best Way To Select A Row Of Data In A Datasource Filtered By Username?

Oct 10, 2007

I'm using the asp.net login controls and am storing the user data in the sql table that get's automaticaly built by visual studio.  I display records based on who is logged in.  Currently i use a Session parameter in my datasource for the user name and store the username in a session variable on the page load event,   Session["UserName"]= User.Identity.Name. 
Is there a way i can use a Profile parameter in my data source and skip setting  session variable all together? I tried putting Name and UserName and User.Identity.Name in the Profile property but nothing seems to work.  Thanks for any help.

View 6 Replies View Related

Transact SQL :: Pass Results From Select To Another Select

Oct 13, 2015

I've got a select as follows:

select computer, count(*) as MissedCount  from WInUpdates_Neededreq
WHERE LoggedDate BETWEEN DATEADD (DAY, - 5, GETDATE()) AND GETDATE() and LastReportTime !< DATEADD (DAY, -5, GETDATE())
group by computer

I need to make a join onto another table but don't want to lose the coutn(*) as MissedCount.

How can I join to another table and still keep the count form the original table.  I want ot join to tblogons.workstationname and return computer from the original query...

View 16 Replies View Related

Export Username / Password To CSV File To Test SP To Output Username / Password

Jun 2, 2014

I put this together to export the user name /password to a csv file to test my SP to output the user name/password.

DECLARE @user_name varchar(50)
DECLARE @psswrd varchar(10)
SELECT @user_name ,@psswrd
FROM ngweb_bulk_enrollments
EXEC master.dbo.xp_cmdshell 'bcp NGDevl.dbo.ngweb_bulk_enrollments out C: est.csv -Sserver1 -T -t, -r
-c'

This works but I don't get the headers in the file. How can I include the headers?

View 7 Replies View Related

How To Pass Paremeter To A Select Statement?

Jul 28, 2006

I have this.
string strConn = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString; string strQuery = "SELECT * FROM enews WHERE ((name_nws LIKE %'" + strSearch + "'%)"; SqlDataAdapter newsResultAdapter = new SqlDataAdapter(strQuery, strConn); //create a new dataset DataSet dsNewsSearch = new DataSet(); //populate the dataset with the "board_mtg_date" table from the database newsResultAdapter.Fill(dsNewsSearch, "enews"); //go through each rows in the dataset foreach (DataRow dr in dsNewsSearch.Tables[0].Rows) { int newsID = Convert.ToInt16(dr["id_nws"]); } I'm trying to pass a value to the Select statement with the variable "strSearch". It kept giving me error on this section.
The error is:
[SqlException (0x80131904): Line 1: Incorrect syntax near 'Challenge'.]"Challenge" is the text I passed it in.

View 17 Replies View Related

T-SQL (SS2K8) :: Pass A Column Name Using Parameter In Select Statement

Sep 5, 2014

I have a temp table that hosts data from a MDX query, I want to select a column from that table by passing in a parameter and then insert to a new table.

Here's the table structure, let's call it #temp

[Product].[Product Hierarchy].[level 03].[Member_CAPTION], [Measures].[Gross Sales]
Bike, 200
Accessory , 100

I have a table in the DB created as [ProductSales]

Here's what works for me:

insert into [ProductSales](Product, Sales)
Select convert(varchar(20), "[Product].[Product Hierarchy].[level 03].[Member_CAPTION]") as 'Product' , convert(decimal(18,2), [Measures].[Data]) as 'Sales'
From #temp

But in reality the product level is not always on level 03, I want to define a parameter @Product and pass it to the select list.

Here's what I tried to do:

Declare @Product varchar(500) = convert(varchar(20), "[Product].[Product Hierarchy].[level 01].[Member_CAPTION]")
Declare @SQL varchar(MAX)
SET @SQL='insert into [ProductSales](Product, Sales)
Select '+@Product+' as 'Product' , convert(decimal(18,2), [Measures].[Data]) as 'Sales'
From #temp'
Exec @SQL

But it threw me error, what is the right way to do it, is it because the double quote or single quote thing?

View 1 Replies View Related

SQL Server 2012 :: Create Variable In Select Query And Use It In Where Clause To Pass The Parameter

Sep 9, 2014

I am writing a stored procedure and have a query where I create a variable from other table

Declare @Sem varchar (12) Null
@Decision varchar(1) Null
Select emplid,name, Semester
Decision1=(select * from tbldecision where reader=1)
Decision2=(select * from tbldecision where reader=2)
Where Semester=@Sem
And Decision1=@Decision

But I am getting error for Decision1 , Decision2. How can I do that.

View 6 Replies View Related

How To Pass Pass The Parameter In SQL Command In SSIS Package

Jul 31, 2006

Hi

   We already used Oracle Datasatage Server the following Query statement for Source and Lookup.here there is parameter maping in the SQl Statement . How can achive in SSIS the Folowing Querystatment?

 

Query 1: (source View Query)
SELECT
V_RDP_GOLD_PRICE.GDR_PRODUCT_ID, V_RDP_GOLD_PRICE.ASSET_TYPE, V_RDP_GOLD_PRICE.PREFERENCE_SEQ, V_RDP_GOLD_PRICE.RDP_PRICE_SOURCE, TO_CHAR(V_RDP_GOLD_PRICE.PRICE_DATE_TIME,'YYYY-MM-DD HH24:MI:SS'), TO_CHAR(V_RDP_GOLD_PRICE.REPORT_DATE,'YYYY-MM-DD HH24:MI:SS'), V_RDP_GOLD_PRICE.SOURCE_SYSTEM_ID
FROM
V_RDP_GOLD_PRICE V_RDP_GOLD_PRICE
WHERE
REPORT_DATE = (select max(report_date) from V_RDP_GOLD_PRICE where source_system_id = 'RM' )



 

Query 2: (look up )

 


SELECT
GDR_PRODUCT_ID,
TO_CHAR(MAX(PRICE_DATE_TIME),'YYYY-MM-DD HH24:MI:SS') ,
TO_CHAR(REPORT_DATE,'YYYY-MM-DD HH24:MI:SS')
FROM
V_RDP_GOLD_PRICE
where
GDR_PRODUCT_ID = :1 and
report_date = TO_DATE(:2,'YYYY-MM-DD HH24:MI:SS')  AND
PRICE_DATE_TIME BETWEEN TO_DATE(:2,'YYYY-MM-DD HH24:MI:SS') - 7) AND TO_DATE(:2,'YYYY-MM-DD HH24:MI:SS')
GROUP BY GDR_PRODUCT_ID, TO_CHAR(REPORT_DATE,'YYYY-MM-DD HH24:MI:SS')



 

please anyone give the sample control flow  and how to pass the parameter?

 

Thanks & regards

Jeyakumar.M

 

View 1 Replies View Related

Get Username

Feb 21, 2002

Hi!! I use nt groups to give access to users. I need to now the name of the user who is connected to a especific database.

I tryed with suser_name() function but it returns null value because ntgroups are used.

if someone now any function that can help me, i will appreciate your help.

Thanks.

View 1 Replies View Related

Username: Sa

Jan 26, 2008

I just installed SQL 2005 Server. I am using SQL Server 2005.
Why do I have to login with the username with "sa"?

I failed to sign in with other usernames.

What is the trick?



Thanks

View 3 Replies View Related

Passing UserName To SQL

Jul 8, 2007

A beginner's question I'm sure.  When visitors have logged into my site, how do I then use their UserName as a parameter in an SQL WHERE clause so that I can pull up their detailed information.  I'm using VB if additional code is required.
Thanks in advance.

View 2 Replies View Related

Username && Password

Oct 4, 2005

I built an eommerce site on my local computer at work. It's now time to
put the site on our server and get things rolling... anyways, I'm
trying to perform an sqldump so I can gather the appropriate text files
so I can upload the database.  Anyways, the sqldump program I am
using requires a username and password to access the sql database.

I am using MSDE and have no clue as to what the username and password may be....

My VisualStudio .Net automatically connects when I work on the site.

Does anyone know what the default username and password may be or what my options are to get this sqldump to work?

Any help would be appreciated.

View 2 Replies View Related

Get NT Username...10-July-01

Jul 10, 2001

Hello out there in SQL land! I'm writing a T-SQL script to create tables and grantlogins to local machine NT accounts. The problem is that I'm sending this script out to about 1700 machines with 1700 different DomainNames!
So hard-coding the domainusername is NOT an option. In other words, non-networked computers. In the T-SQL command:

EXEC sp_grantlogin [DomainUsername]
-OR-
EXEC sp_grantdbaccess [DomainUsername]

note: Domain= @@SERVERNAME
Username = Jib

I want to have a variable of some sort pass the DomainName & concatenated username in order to grant login the SQL Server for the NT user. Any help would be greatly appreciated.
Thanks!

View 1 Replies View Related

Suggest Username

Aug 1, 2006

hey can anyone suggest me how to write the efficient( a bit faster) stored proc to generate alternative usernames( with logical variations like the one of hotmail ) if provided one is already present in database... :)

View 5 Replies View Related

Username & Password

Dec 13, 1998

how do you send SQL Server the proper username and password in ASP Scripts?

So far, I have: Connection.Open "DSN=DSNname;pwd=password"

Where does username play in all this and what is its format.

Appreciate any help....

View 2 Replies View Related

How Can I Get The Username From An Application?

Aug 9, 2004

Hi everybody,

Here the environment is application in 3 layers.
So the user in his client machine, access the application in an application server that sends the request to my sql server database server.
My problem is: when I run sp_who from Query Analyzer, I see the host name that is pre-defined inside code application. But, actually, I need to know the user who is requesting the transactio so I can know right the person who is slowing my database performance....
Do you know, any function, procedure or anything else that I can use in the application code in order to provide the user or the host name from the client machine?????
I hope some answers...

Thank you all,

View 7 Replies View Related

Using UserName As A PK VS. UserId

Jan 6, 2005

Hello

Currently, I am using a varchar "UserName" as a primary key instead of an Identity or GUID.

System Info:
When user's sign up they provide the "UserName" that is used as a PK.
Creating a message board type web application.
UserNames will never change.
UserNames are used extensively as FK's in other Tables.
We want to scale well.

Does anyone know the implications?
I understand Joins are faster on numerical values than strings but we will not be performing many joins.

In my case is it better to use Identity as a PK or is it better to use a varchar for a "Users" table?

Thanks
jenn

View 1 Replies View Related

Windows Username

Apr 25, 2008

Hi all,
I want create a trigger that will log all modification to a table.
I need to identify the username that modified the data.
Here is my problem :
- they are connected to a Terminal Server so stationName il always TSName
- They are using an application I cannot modify that always use the same login information using SQL authenticationMode

So I need to be able to get their Windows session Username.

Is there any way I can do that in my trigger ?

Thanks

View 5 Replies View Related

Query Help - Get Last Username?

Apr 22, 2006

Hi, I hope this is the right place to post this. I am pretty much stuck but think I am doing pretty good so far as I am getting more and more into SQL

using SQL Server 2000 here.

 

I want to be able to get the last username who replied to a topic. The "DateOfLastReply" works great, it gives me the last date of a reply to a topic so pretty much along with this, I want to get who it was that replied last. Any ideas? so far, I have this but it isnt correct:




SELECT Threads.[ID] 'ThreadID', ThreadName, DateOfCreation 'DateCreated',

(SELECT TOP 1 DateOfReply FROM Replies WHERE Replies.ThreadID = Threads.[ID] ORDER BY DateOfReply DESC) 'LastReplyDate',

(SELECT TOP 1 e.Username FROM Replies, Threads WHERE Replies.UserID = e.[ID] AND Threads.[ID] = Replies.ThreadID AND Threads.ThreadStarterUser = e.[ID] ORDER BY DateOfReply DESC) 'LastUserReplied', --HERE

(SELECT COUNT(ReplyID) FROM Replies WHERE ThreadID = Threads.[ID]) 'NumberOfReplies',
e.username 'UsernameCreator'
FROM Threads
INNER JOIN Users e ON
e.[ID] = ThreadStarterUser

 

View 6 Replies View Related

Username Rather Than Sa In Sql Server 2000

Aug 16, 2004

how can i change the username of SQL Server 2000 from sa to another username?
thank you for the help and for the time

View 7 Replies View Related

How To Set Up A Username And Password For MSDE

Jan 1, 2005

Hi,

I have installed MSDE using the following parameter:

commandline> setup SAPWD="MySAPwd"

now all was set up... when i opened the osql utility..i wasnt able to login... it kept asking me the login name ans password...

i entered my windows login name which is 'home' and entered 'kham00s' as the password... it didnt work... then i entered my windows login name again which is 'home' and entered 'OTHERPASSWORD' as the password which is my system password...but did not work either...

then i logged in using :

commandline> osql -E

It successfully logged in... and i was able to create databases and tables...

can someone tell me how to set a username and password for MSDE please... so that i can connect to MSDE using WebMatrix...

i m coming from a PHP/MySQL background so i know SQL and stuff... but dont know how to handle and configure MSSQL...

waiting for the response..
thanks in advance...
Bye.
Kamran.

View 6 Replies View Related

_ In NT UserName. Looking For Janne Hakulinen

Jan 11, 1999

I want to establish logging using NT Security. The problem is that user names in NT have underscore(_). When I establish NT Scurity in SQL security manager, SQL Server tries to add blank names as login id and they will not go through. Is it manadatory to remove underscore from username?

Because of structrual hierarchy, I have different groups in NT to be mapped to SQL Server groups and each group has different permission on SQL tables. In some cases we might have same users in more than one group. I read that it is not possible if you use NT integrated security. Is there any thing that can be worked around this and is this problem still exists in SQL 7.

Janne Hakulinen gave me a reply (Appreciate that) but when I did as he said, I got no success. So I am asking him to reply me at alim@goldline.net and let me send him an e-mail.

Thank you in advance
Ali Malekshahi

View 1 Replies View Related

HELP -- Password & Username Recovery

Aug 16, 2000

I need to get into a database and need the password and username for a Microsoft SQL Server v.6.5 database. Can you help or do you know someone else who can? This database is owned by us and this is a "legal" project.

Thank you.

Michael A. Wise
Manager, MIS/IT
EBARA International Corporation
Cryodynamics, Electric Motor, Standard Pumps Divisions
"World's Leader in Liquefied Gas Pumps and Turbines"
350 Salomon Circle
Sparks, Nevada, USA 89434
775-356-2796, xt. 215; FAX: 775-356-2884
mailto:mwise@ebaraintl.com
www.ebara.co.jp/indexe.html
www.ebaratech.com
www.pumpsebara.com

View 1 Replies View Related

How To Connect To DB With Username And Passwd?

May 23, 2006

Hi I've created a login in my SQL Server 2005 like this:

CREATE LOGIN testuser
WITH PASSWORD = 'TestPWD';
USE DB1;
CREATE USER testuser FOR LOGIN testuser;
GO

now i want to connect from a c# app with the following connection STring
"Data Source=TURM21;Initial Catalog= Db1; Database= Db1 ; USER = testuser; PASSWORD = TestPWD; pooling=false; "

and i get the following Exception:
SqlConnection Handle : System.Data.SqlClient.SqlException: A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

CAn somebody help me? Whats wrong? Is it my connection string?

Greetz

View 2 Replies View Related

Difference Between Username And Groupname

Jun 8, 2006

I set up a group within an SQL Server database, of which I am a member. In some visual basic code, I do a dislay of user names.

My question: why does the code show my individual name (Servermyname) as opposed to showing the group name I want to see? I have confirmed that the only user of the database is the group, and not an individual user name.

Any ideas? Thanks!

*********************************************************************
This forum is best viewed with a computer. Questions asked freely. Confusion happily shared.

View 3 Replies View Related

Change Username And Password

Sep 30, 2006

Hello

I newly installed the SQL Server 2005.During installation i chose the option Mixed Mode.I aslo did nit mention any user name and password to the SQL Server.Iam able successfully create Databases using the SQL Server Management Studio.
My problem iam unable to connec to the SQL Server from my .net windows application.My application code is

Dim strCon As String
Dim sValue As String
Dim strQuery As String
Dim dsEventTransac As New DataSet
Dim daEventTransac As New SqlClient.SqlDataAdapter
Dim rowCount As New Integer
Dim oWebService As New WebReference.TkmService
'Dim nwRow As DataRow
'Dim delCmd As SqlClient.SqlCommand


strQuery = "SELECT * FROM EventTransaction"

strCon = "Data Source=localhost;integrated security=SSPI;initial catalog=KmsDb;User ID=sa;password="
objCon = New SqlClient.SqlConnection(strCon)
If objCon.State = ConnectionState.Closed Then
objCon.Open()
End If
daEventTransac = New SqlClient.SqlDataAdapter(strQuery, objCon)
Dim cmdBuilder As New SqlClient.SqlCommandBuilder(daEventTransac)
daEventTransac.Fill(dsEventTransac)

'update the DataAdapter
daEventTransac.Update(dsEventTransac)
oWebService.Url = "http://192.168.0.10/TkmService1/TkmService.asmx"

''display the table in a grid
dgEventTransac.DataSource = dsEventTransac.Tables(0)

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub

Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs) Handles dgEventTransac.Navigate

End Sub
End Class

When i donot specify user ID and password i get connected correctly.But when i run the above code i get an error
"Unable to connect to the remote server"
Now i want to change the username and password.Please tell me how to do

View 2 Replies View Related

Setting Username And Password

Jun 11, 2007

How do you set a username and password for a database in SQL Server 2005?

View 1 Replies View Related

How To Clear SQL Authenication Username?

Oct 16, 2007

Hi,

I had deleted the login and user in my SQL 2005 database. However, each time when i connect to my database using the SQL enterprise manager, I can still see the deleted username under the login. It seems that the username is stored or cache somewhere after the first time that I have login. Does anyone know how to clear it? I am using SQL 2005 authenication method on 2003 Server machine. Thanks.

Regards,

View 14 Replies View Related

Index For Username/password

Dec 28, 2005

Does this make sense for a logon table:CREATE TABLE Logon(ID INT NOT NULL IDENTITY PRIMARY KEY,name VARCHAR(15) NOT NULL,password VARCHAR(15) NOT NULL)GOCREATE UNIQUE INDEX IX_Logon_Name ON Logon(name)CREATE INDEX IX_Logon_NameAndPassword ON Logon(name,password)GOI do want the name to be unique but also will search frequently on bothname & password. Is this how it should be done? I don't fullyunderstand the difference between placing a single index in name &password VS one on both name & password.

View 12 Replies View Related

DB Hostname, Username, Password Etc

Jun 25, 2007

I'm trying to get into an installation of v.6.5 to use with anotherserver and I need the following information:Database hostnameDatabase nameDatabase usernaneDatabase passwordIs this information available anyplace within the installation files?I'm not asked for uname and pwd to get into the database.Thanks!

View 1 Replies View Related

Reports Asking For Username And Password

May 18, 2007

I have two questions -



1. I have deployed the reports on our webserver. When I access the link http://servername/Reports from IE it asks me for a username and password the first time. I tried all the passwords including admin user/pwd but the dialog remains there. I close IE and start again I can access the reports. For your information, the checkbox 'Save my password' is checked in the reports. Does anyone know why the username/password dialog appears the first time?



2. Sometimes some of us get a 'Page cannot be displayed' while the others can access it. I have to start Reporting services and everyone can access the reports. Any ideas?



Thanks!!

View 3 Replies View Related

Specifying A Username And Password For SMTP

Nov 9, 2005

How do I specify the SMTP username and password for reporting services?  It seems like I can specify one for SQLmail, but not reporting services?  How the heck is anyone going to use the email feature of reporting services without being able to specify smtp credentials or making their mail server an open relay for spam??

View 16 Replies View Related







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