Showing posts with label username. Show all posts
Showing posts with label username. Show all posts

Monday, March 26, 2012

help on join statement

I have two tables:

tblUserData
UserName
UserCode

tblBlogs
UserCode
BlogText

I have an SP which takes the username as a variable.

How can I select all blogtext from tblBlogs where the usercode belonging to the username in tblUserdata is equal to the usercode in tblBlogs?


so select all blogs for a specfic username...

SELECT TB.* FROM tblBlogs TB

JOIN tblUserData TUD ON TB.Usercode = TUD.UserCode

WHERE TUD.UserName = @.UserName

Monday, March 12, 2012

Help needed on select and insert query

a bit of a begginer's request here.
I have a table called t_user in which username is the primary key and one of
the fields is a decimal called bsl.
I'm trying to write a stored procedure that selects the right record based
on the username (input from a cookie) and then inserts the bsl value based o
n
the users input into a textbox on the asp.net page
the stored proc code is
CREATE PROCEDURE addbsl
@.bsl decimal,
@.username varchar(20)
AS
SELECT username FROM t_user
WHERE username = @.username
insert into t_user (bsl) values (@.bsl)
GO
and when i run it in the query analyser it tells me:
Server: Msg 515, Level 16, State 2, Procedure addbsl, Line 8
Cannot insert the value NULL into column 'username', table
'FYProj.dbo.t_user'; column does not allow nulls. INSERT fails.
The statement has been terminated.
(1 row(s) affected)
Stored Procedure: FYProj.dbo.addbsl
Return Code = -6
I understand that it is trying to insert a username as well but cannot
because you cannot enter a null value but I don't want it to input a sername
i just want it to insert data into the record with the specified username
Is there a way to change the sproc to get it to work or am i just taking the
wrong approach?You will have to use an UPDATE statement to update an existing row. INSERT
always insert a new row.
Hello neil_pat,

> a bit of a begginer's request here.
<snip>
Lasse Vgsther Karlsen
http://www.vkarlsen.no/
mailto:lasse@.vkarlsen.no
PGP KeyID: 0x0270466B

Sunday, February 19, 2012

Help me please about username and password

How to set user and password connect to Database server from other program
when Sql server 2000 authentication by Windows ?
And How Change Windows authentication to Sql server authentication.
To connect via a different user and password you have to modify the
connection string that you are connecting with, but thats only valid
for SQL Server Authentication.You can=B4t specify the Windows user and
password as though this is Integrated Authentication. As you didn=B4t
state how (with which program etc) you are connecting its hard to give
you a suggestion for that, but if you are using the .NET Framework you
could start a new thread and impersonate the thread as a special
Windows user, then you could use impersonation even you are logged on
with a different user.
HTH, jens Suessmeyer.

Help me please about username and password

How to set user and password connect to Database server from other program
when Sql server 2000 authentication by Windows ?
And How Change Windows authentication to Sql server authentication.To connect via a different user and password you have to modify the
connection string that you are connecting with, but thats only valid
for SQL Server Authentication.You can=B4t specify the Windows user and
password as though this is Integrated Authentication. As you didn=B4t
state how (with which program etc) you are connecting its hard to give
you a suggestion for that, but if you are using the .NET Framework you
could start a new thread and impersonate the thread as a special
Windows user, then you could use impersonation even you are logged on
with a different user.
HTH, jens Suessmeyer.