Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Wednesday, March 21, 2012

Script Task

How do I specify a different script language in my "Script Task"?. The default is Visual Basic .NET. I would like to use c# for all my scripting task.

Thanks,

Sergio

You can only use VB.NET in 2005. You will be able to use C# in SQL Server 2008.
|||

Thanks for your reply, I guess I will be forced to learn vb.net. I am a c# developer and unfortunally this will slow me down since there will be a learning curve.

Thanks,

Sergio

|||

Sergio wrote:

Thanks for your reply, I guess I will be forced to learn vb.net. I am a c# developer and unfortunally this will slow me down since there will be a learning curve.

Thanks,

Sergio

I promise you, if you know C# its not a very steep learning curve at all.

Saturday, February 25, 2012

scramble password

Hello group,
I have a fairly simple question (hopefully simple anyway). I have a table
that has basic application user data: name, address, city, email, password.
I now have a requirement to in bulk take the password and encrypt them. The
y
have already given me the function name to use: ToBase64Sting().
Here is the question; how can I run the password field into this function in
a stored procedure? I am not familier with this function but have done some
reading. I suspect I would just place the scrambled password into a second
field and delete the original, then rename the field. Any suggestions?update YourTable
set password = dbo.ToBase64Sting(password)
try doing this first and look at the the 2 fields
select password ,dbo.ToBase64Sting(password ) from YourTable
http://pixsells.blogspot.com
"Rich" wrote:

> Hello group,
> I have a fairly simple question (hopefully simple anyway). I have a table
> that has basic application user data: name, address, city, email, password
.
> I now have a requirement to in bulk take the password and encrypt them. T
hey
> have already given me the function name to use: ToBase64Sting().
> Here is the question; how can I run the password field into this function
in
> a stored procedure? I am not familier with this function but have done so
me
> reading. I suspect I would just place the scrambled password into a secon
d
> field and delete the original, then rename the field. Any suggestions?|||Rich wrote:
> Hello group,
> I have a fairly simple question (hopefully simple anyway). I have a
> table that has basic application user data: name, address, city,
> email, password. I now have a requirement to in bulk take the
> password and encrypt them. They have already given me the function
> name to use: ToBase64Sting().
> Here is the question; how can I run the password field into this
> function in a stored procedure? I am not familier with this function
> but have done some reading. I suspect I would just place the
> scrambled password into a second field and delete the original, then
> rename the field. Any suggestions?
Is the function they gave you a SQL Server callable function? If so, you
can just update the table directly, assuming the return value from the
function (which is likely just ASCII) is compatible with the data type
you are using for the column in the table. Something like:
Update
dbo.MyTable
Set
Password = dbo.ToBase64String(Password)
BTW, why are you storing passwords in the database? Base64 is not an
encryption scheme. It is an encoding scheme, used mainly by email system
to send attachments. Base64 is not secure and anyone with internet
access will be able to turn that Base64 value into the original
password. So, you may want to reconsider storing passwords in the
database.
David Gugick
Quest Software
www.imceda.com
www.quest.com|||Hello David,
see http://support.microsoft.com/defaul...kb;en-us;317535
I thought that this function would be available from the SQL Server however
this function does not appear to be part of TSQL. I tried the code fragment
you posted and I am thinking this will not work. This functionis something
the my web developers I work with are using so you comment about being secur
e
over the web scares me...
Rich
"David Gugick" wrote:

> Rich wrote:
> Is the function they gave you a SQL Server callable function? If so, you
> can just update the table directly, assuming the return value from the
> function (which is likely just ASCII) is compatible with the data type
> you are using for the column in the table. Something like:
> Update
> dbo.MyTable
> Set
> Password = dbo.ToBase64String(Password)
> BTW, why are you storing passwords in the database? Base64 is not an
> encryption scheme. It is an encoding scheme, used mainly by email system
> to send attachments. Base64 is not secure and anyone with internet
> access will be able to turn that Base64 value into the original
> password. So, you may want to reconsider storing passwords in the
> database.
>
> --
> David Gugick
> Quest Software
> www.imceda.com
> www.quest.com
>|||I see what you are doing we used to do the same
You use .NET encryption the function you mentioned is a .NET function
Have one of your web guys write a script to loop through the table and
update the password with the encrypted string
There is no way you can do this in SQL server 2000 (as far as I know that is
)
http://sqlservercode.blogspot.com/
"Rich" wrote:
> Hello David,
> see http://support.microsoft.com/defaul...kb;en-us;317535
> I thought that this function would be available from the SQL Server howeve
r
> this function does not appear to be part of TSQL. I tried the code fragme
nt
> you posted and I am thinking this will not work. This functionis somethin
g
> the my web developers I work with are using so you comment about being sec
ure
> over the web scares me...
> Rich
> "David Gugick" wrote:
>|||Hello SQL,
yes, yes, yes, you understand! I just need a loop to update that field with
that function they suggested! The problem is I will end up make the "loop".
I am looking at making this looper in MSAccess, connect to the table, run th
e
loop and be done with this. I just need to understand if this is a standard
VB function that I can drop the field into the function and let the thing
return the encrypted password.
Rich
"SQL" wrote:
> I see what you are doing we used to do the same
> You use .NET encryption the function you mentioned is a .NET function
> Have one of your web guys write a script to loop through the table and
> update the password with the encrypted string
> There is no way you can do this in SQL server 2000 (as far as I know that
is)
> http://sqlservercode.blogspot.com/
>
> "Rich" wrote:
>|||I don't know if MS Access will work
We used C# ASP.NET but I was not involved with this process
I don't know if MS Access can access those functions since they are .NET
specific
try one of the .NET newsgroups for this question
http://sqlservercode.blogspot.com/
"Rich" wrote:
> Hello SQL,
> yes, yes, yes, you understand! I just need a loop to update that field wi
th
> that function they suggested! The problem is I will end up make the "loop
".
> I am looking at making this looper in MSAccess, connect to the table, run
the
> loop and be done with this. I just need to understand if this is a standa
rd
> VB function that I can drop the field into the function and let the thing
> return the encrypted password.
> Rich
> "SQL" wrote:
>|||Store a hash of the password not the password itself. Hash the input and
compare both hashes to determine if they are the same. There are some
undocumented hash functions in SQL (don't remember the names) but you really
should hash it then send it to the server for comparison rather than send
the plain text password across the wire.
Derek Davis
ddavis76@.gmail.com
"SQL" <SQL@.discussions.microsoft.com> wrote in message
news:F32DD3BB-A829-456F-AF2A-18AA6D1FEEDB@.microsoft.com...
>I don't know if MS Access will work
> We used C# ASP.NET but I was not involved with this process
> I don't know if MS Access can access those functions since they are .NET
> specific
> try one of the .NET newsgroups for this question
> http://sqlservercode.blogspot.com/
>
> "Rich" wrote:
>

Tuesday, February 21, 2012

SCOPE_IDENTITY() vs. @@IDENTITY

I have a basic C# application that is trying to INSERT a row and get the ID. Really simple; there are no triggers, no stored procs or functions were involved, the app is single threaded, there is currently only one user. I have a really basic table with a INTEGER IDENTITY PK column. All very standard.

If I do the INSERT followed by a "SELECT @.@.IDENTITY" on the same connection, it works correctly.
If I use SCOPE_IDENTITY() instead, it returns NULL. I use SCOPE_IDENTITY on a variety of other occassions and it works fine. Why would this be? I thought SCOPE_IDENTITY() was the preferred replacement to @.@.IDENTITY.

I guess what I have is satisfactory but this was frustrating and I want to know why.

This is on SQL Server 2000 Standard edition with version SP3a + hot fixeshai roger,

SCOPE_IDENTITY and @.@.IDENTITY will return last identity values generated in any table in the current session. However, SCOPE_IDENTITY returns values inserted only within the current scope. @.@.IDENTITY is not limited to a specific scope.

This is the example given in BOL

Suppose if you have two tables, T1 and T2, and an INSERT trigger defined on T1. When a row is inserted to T1, the trigger fires and inserts a row in T2. This scenario illustrates two scopes: the insert on T1, and the insert on T2 as a result of the trigger.

Assuming that both T1 and T2 have IDENTITY columns, @.@.IDENTITY and SCOPE_IDENTITY will return different values at the end of an INSERT statement on T1.

@.@.IDENTITY will return the last IDENTITY column value inserted across any scope in the current session, which is the value inserted in T2.

SCOPE_IDENTITY() will return the IDENTITY value inserted in T1, which was the last INSERT that occurred in the same scope. The SCOPE_IDENTITY() function will return the NULL value if the function is invoked before any insert statements into an identity column occur in the scope.

Hope this relives u of ur frustration|||Yes, I read BOL and understand the documented theoretical and conceptual differences between the two. However, those differences don't apply to my situation.

There is only one thread, one process, one identity value, and one table involved. There are no triggers or functions or stored procs involved. It's a simple INSERT/get ID situation. And @.@.IDENTITY works and SCOPE_IDENTITY doesn't work which just doesn't make any sense according to what I've read.

SCOPE_IDENTITY plzzzzz help me

this is my code, i really want a basic easy way without using procedures to do a simple task to response.write(last record added) using scope_identity...
asp.net/VB
===================================================================================
Sub click_addnew(sender as object, e as system.eventargs)

Dim oDR as System.Data.SQLClient.SQLDataReader
Dim oCom As System.Data.SQLClient.SqlCommand
Dim oConn as System.Data.SQLClient.SQLConnection
Dim recnumber as integer
try
oConn = New System.Data.SQLClient.SQLConnection ("server=xxx.xxx.xx; initial catalog=xxx;uid=xxx;pwd=xxx")
oConn.Open()
oCom = New System.Data.SQLClient.SqlCommand()
oCom.Connection = oConn

oCom.CommandText = "INSERT INTO hooliganproducts (hooligantitle, hooliganprice, hooligandescription, hooliganpartno, hooligancata) VALUES ('test' , '100' , 'test' , 'test' , 'test') select scope_identity"
oDR = oCom.ExecuteReader()
response.Write(oDR) 'THIS IS WHERE I WANT TO DISPLAY THE NUMBER OF THE LAST RECORD

catch
Response.Write("Error:" & err.Description)
Finally
oDR = Nothing
oCom = Nothing
oConn.Close()
oConn = Nothing
end try

End Sub
=============================================================================

Please can someone help, feel like i have been banging my head up a brick wall all day, have spent the whole day trying to find an answer.
Thank you in advance
Darren

Multiple SQL commands in a batch should be separated by semicolons (;). Try putting a semicolon between theINSERT statement and theselect scope_identity statement.
|||(1) You need brackets after SCOPE_IDENTITY as in SCOPE_IDENTITY().
(2) You might want to use ExecuteScalar since you are only getting backone value. So you can also avoid the overhead of creating a datareader.
So your code would look something like :
oConn = New System.Data.SQLClient.SQLConnection ("server=xxx.xxx.xx; initial catalog=xxx;uid=xxx;pwd=xxx")
'oConn.Open() - OPEN ONLY WHEN YOU NEED AND CLOSE IMMEDIATELY.
oCom = New System.Data.SQLClient.SqlCommand()
oCom.Connection = oConn
oCom.CommandText= "INSERT INTO hooliganproducts (hooligantitle, hooliganprice,hooligandescription, hooliganpartno, hooligancata) VALUES ('test' ,'100' , 'test' , 'test' , 'test') select SCOPE_IDENTITY()"
Dim newId as Integer
try
oConn.Open()
newId = oCom.ExecuteScalar()
response.Write(newId) 'THIS IS WHERE I WANT TO DISPLAY THE NUMBER OF THE LAST RECORD

catch
Response.Write("Error:" & err.Description)
Finally
oCom = Nothing
oConn.Close()
oConn = Nothing
end try
|||Thank you both. feel much better now, got it working.