Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2007, 07:04 PM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

please Eric, give me some help with this if we can:

I made a script that generate a long sql file with insert's.... identify, etc! To tun under asp.net 1.1 with thePhile
I used your excelent CopyTableData.cs.txt as inspiration!

My big problem is:
Code:
ElseIf (sqlProviderType.ToString = "Binary") Then
            If (dr(col) Is DBNull.Value) Then
                result += "NULL, "
            Else
                Dim b() As Byte = New Byte(dr.GetBytes(col, 0, Nothing, 0, Int.MaxValue))
                dr.GetBytes(col, 0, b, 0, b.Length)
                'put here something like result += b.toString                    or convert.BytetoString(b)


Asp.Net 1.1 don't support:
"dim xxx() as byte = New byte(....)
and
Int.MaxValue



I tested my script and it is perfect (without binary fields)
Binary and bytes is a big problem for me!
I spend all night "googling" for solution without success!

I just need to convert my datarow of datareader into a string like this:
0xD62F739DA2796769AF9E727E7905F91A369F44A

in order to download all by db based on thephile and make my changes to turn it into sql2005 to run under thebeerhouse!

Please, if you can help me with this i will by much thankful

Max

 
Old July 9th, 2007, 07:27 PM
Friend of Wrox
 
Join Date: Mar 2006
Posts: 310
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As I wrotte on Asp.Net Forum, I found a solution for my problem!

After I generate my huge SQL file, I run this script:

Code:
declare @pstrout nvarchar(4000)
    ,@i int
    ,@firstnibble int
    ,@secondnibble int
    ,@tempint int
    ,@hexstring char(16)
    ,@cbytesin int
    ,@startoffset int
    ,@fsetprefix bit
    ,@pbinin varbinary(8000)
    ,@counter int
    ,@curPass varchar(8000)
    ,@curName varchar(15)


set @startoffset = 1
set @fsetprefix = 1
set @cbytesin = 0
set @counter = 0

CREATE TABLE #TempUsers
(
    ID             int IDENTITY PRIMARY KEY,
    querystr        varchar(600)
)
    while @counter < (select (max(UserID)) from accounts_Users)
    begin
      set @counter = @counter + 1
      set @pbinin = (select password from accounts_users where userid = @counter)
      Set @curName = (select UserName from accounts_users where userid = @counter)
      set @curPass = NULL
      set @pstrout = NULL

    if (@pbinin IS NOT NULL)
    begin    
        select @i = 0
                ,@cbytesin = case when (@cbytesin > 0) then @cbytesin else DATALENGTH(@pbinin) end
                ,@pstrout =  case when (@fsetprefix = 1) then N'0x' else N'' end
                ,@hexstring = '0123456789abcdef'

        if ( ((@cbytesin * 2) + 2 > 4000) or ((@cbytesin * 2) + 2 < 1) )
            --select NULL
            Set @curPass = NULL

        if ( ( @startoffset > @cbytesin ) or ( @startoffset < 1 ) )
            --select NULL
            Set @curPass = NULL

        --
        -- do for each byte
        --
        while (@i < @cbytesin)
        begin
            --
            -- Each byte has two nibbles
            -- which we convert to character
            --
            select @tempint = cast(substring(@pbinin, @i + @startoffset, 1) as int)
            select @firstnibble = @tempint / 16
            select @secondnibble = @tempint % 16

            --
            -- we need to do an explicit cast with substring 
            -- for proper string conversion. 
            --
            select @pstrout = @pstrout +
                cast(substring(@hexstring, (@firstnibble+1), 1) as nvarchar) +
                cast(substring(@hexstring, (@secondnibble+1), 1) as nvarchar)

            select @i = @i + 1
        END
    END

    -- All done
    --select @pstrout
    Set @curPass = @pstrout

    IF (@curPass IS NOT NULL AND @curName IS NOT NULL)
      BEGIN
       INSERT INTO #TempUsers (querystr) VALUES
       ('UPDATE FORUMS_ACCOUNTS SET PASSWORD = ' + @curPass + ' WHERE UserID = ' + CONVERT(VARCHAR(4), @counter) + ' AND USERNAME =' + @curName )
        END
    END

SELECT querystr FROM #TempUsers

DROP TABLE #TempUsers
Now I can move on to the upgrade from version 1.1 to version 2!

I just need to make a script that convert topics+replies tables into one single table (posts)

But this is easier... Because i don't need anymore to work with binary fields! UFFFFFFFFFFFFFFFFFFFFFFFFFFF! This was hard. On google i don't found one single way to select binary fields into asp.net application.
Even on my custom queryAnalyzer from my hoster company I couldn't list my passwords because somehow the script made by this company ate "0" from my binary and if I update my db using this fields password didn't match

0x0ghdyr5630jfhg095 "="
0x0ghdyr563jfhg095

With a 1000 users, It is impossible to know where are the eaten "zero"



(sorry my english)

 
Old July 10th, 2007, 11:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

>Asp.Net 1.1 don't support:
> "dim xxx() as byte = New byte(....)
> and
> Int.MaxValue

Sure it does. My code was developed in v1.1. The problem is that you didn't convert C# to VB correctly.

But I guess it doesn't matter since you found a new way to do it.

Eric






Similar Threads
Thread Thread Starter Forum Replies Last Post
importing and exporting database with multi-langua lenseere Oracle 0 November 30th, 2007 07:34 PM
importing and exporting database in multi-language lenseere General .NET 0 November 29th, 2007 04:47 PM
Problem importing namespace netsu ASP.NET 1.0 and 1.1 Basics 1 March 16th, 2007 02:03 PM
Problem importing CSV hman MySQL 0 January 6th, 2007 09:13 AM
Exporting/Importing error to EXCEL haasf Access 1 December 4th, 2003 09:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.