Connecting Tech Pros Worldwide Forums | Help | Site Map

Inserting unicode characters into a database using RecordSet.Update

Roger Withnell
Guest
 
Posts: n/a
#1: Apr 6 '06
I'm using ASP, VBScript and SQL Server.

I'm also using UTF-8 character set and so my codepage is 65001 and SQL
Server datatype nvarchar.

I can insert unicode characters correctly into the database table using
INSERT.... (field1) ...VALUES ......... (N'Characters').

How do I do this using Rs.Update viz-a-viz:

Rs.Open .......
Rs.New
Rs("Field1") = "Characters"
Rs.Update

Thanking you in anticipation.



Bob Barrows [MVP]
Guest
 
Posts: n/a
#2: Apr 6 '06

re: Inserting unicode characters into a database using RecordSet.Update


Roger Withnell wrote:[color=blue]
> I'm using ASP, VBScript and SQL Server.
>
> I'm also using UTF-8 character set and so my codepage is 65001 and SQL
> Server datatype nvarchar.
>
> I can insert unicode characters correctly into the database table
> using INSERT.... (field1) ...VALUES ......... (N'Characters').
>[/color]
Since you can do it this way ...
[color=blue]
> How do I do this using Rs.Update viz-a-viz:
>[/color]
why would you ever want to use a recordset for updating data in an asp
application?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Roger Withnell
Guest
 
Posts: n/a
#3: Apr 6 '06

re: Inserting unicode characters into a database using RecordSet.Update



"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:uq6gysaWGHA.404@TK2MSFTNGP05.phx.gbl...[color=blue]
> Roger Withnell wrote:[color=green]
>> I'm using ASP, VBScript and SQL Server.
>>
>> I'm also using UTF-8 character set and so my codepage is 65001 and SQL
>> Server datatype nvarchar.
>>
>> I can insert unicode characters correctly into the database table
>> using INSERT.... (field1) ...VALUES ......... (N'Characters').
>>[/color]
> Since you can do it this way ...
>[color=green]
>> How do I do this using Rs.Update viz-a-viz:
>>[/color]
> why would you ever want to use a recordset for updating data in an asp
> application?[/color]

Because I'm inserting images at the same time, creating a thumbnail and a
main image, using AspUpload and AspJpeg.


Dave Anderson
Guest
 
Posts: n/a
#4: Apr 6 '06

re: Inserting unicode characters into a database using RecordSet.Update


Roger Withnell wrote:[color=blue][color=green]
>> why would you ever want to use a recordset for updating data
>> in an asp application?[/color]
>
> Because I'm inserting images at the same time, creating a
> thumbnail and a main image, using AspUpload and AspJpeg.[/color]

You can still accomplish that without using recordsets. Assign the
properties of the File.Binary property to a parameter of an ADODB.Command
Object, for example.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.


Roger Withnell
Guest
 
Posts: n/a
#5: Apr 6 '06

re: Inserting unicode characters into a database using RecordSet.Update



"Dave Anderson" <GTSPXOESSGOQ@spammotel.com> wrote in message
news:eERoTNcWGHA.4484@TK2MSFTNGP02.phx.gbl...[color=blue]
> Roger Withnell wrote:[color=green][color=darkred]
>>> why would you ever want to use a recordset for updating data
>>> in an asp application?[/color]
>>
>> Because I'm inserting images at the same time, creating a
>> thumbnail and a main image, using AspUpload and AspJpeg.[/color]
>
> You can still accomplish that without using recordsets. Assign the
> properties of the File.Binary property to a parameter of an ADODB.Command
> Object, for example.
>
>
>
> --
> Dave Anderson
>
> Unsolicited commercial email will be read at a cost of $500 per message.
> Use of this email address implies consent to these terms.[/color]

I'd rather not change the code I have already. Is it not possible to insert
the correct Unicode characters into the table using Rs.Update?


Anthony Jones
Guest
 
Posts: n/a
#6: Apr 7 '06

re: Inserting unicode characters into a database using RecordSet.Update



"Roger Withnell" <rogerREMOVE@THISupperbridge.co.uk> wrote in message
news:1144348390_1125@sp6iad.superfeed.net...[color=blue]
> I'm using ASP, VBScript and SQL Server.
>
> I'm also using UTF-8 character set and so my codepage is 65001 and SQL
> Server datatype nvarchar.
>
> I can insert unicode characters correctly into the database table using
> INSERT.... (field1) ...VALUES ......... (N'Characters').
>
> How do I do this using Rs.Update viz-a-viz:
>
> Rs.Open .......
> Rs.New
> Rs("Field1") = "Characters"
> Rs.Update
>
> Thanking you in anticipation.
>
>[/color]

Have you tried it? Did it work?
What do imagine you might need to change in the above to make it work?




Bob Barrows [MVP]
Guest
 
Posts: n/a
#7: Apr 7 '06

re: Inserting unicode characters into a database using RecordSet.Update


Roger Withnell wrote:[color=blue]
> I'd rather not change the code I have already.[/color]

Even if the change results in a more efficient, better-performing
application?

At the very least, since you are processing multiple records, you should
open your recordset using adLockOptimisticBatch for the lock type,
disconnect it (by setting the ActiveConnection property to nothing and
closing your connection), add your records using Update, reconnect it (by
opening the connection and setting the ActiveConnection property to the
opened connection object) and use updateBatch to send the new records to the
database.
[color=blue]
> Is it not possible to
> insert the correct Unicode characters into the table using Rs.Update?[/color]

Of course it is. All I can do is repeat Anthony's question: have you tried
it?

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Roger Withnell
Guest
 
Posts: n/a
#8: Apr 7 '06

re: Inserting unicode characters into a database using RecordSet.Update



"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:uLX6ZdkWGHA.4212@TK2MSFTNGP02.phx.gbl...[color=blue]
> Roger Withnell wrote:[color=green]
>> I'd rather not change the code I have already.[/color]
>
> Even if the change results in a more efficient, better-performing
> application?
>
> At the very least, since you are processing multiple records, you should
> open your recordset using adLockOptimisticBatch for the lock type,
> disconnect it (by setting the ActiveConnection property to nothing and
> closing your connection), add your records using Update, reconnect it (by
> opening the connection and setting the ActiveConnection property to the
> opened connection object) and use updateBatch to send the new records to
> the
> database.
>[color=green]
>> Is it not possible to
>> insert the correct Unicode characters into the table using Rs.Update?[/color]
>
> Of course it is. All I can do is repeat Anthony's question: have you tried
> it?
>
> Bob Barrows
> --
> Microsoft MVP -- ASP/ASP.NET[/color]

I am inserting one record, not multiple records. A record has a subject
and a caption (both nvarchar), a thumbnail and a main image both created
from the same original image file, using AspUpload and AspJpeg to upload and
re-size the images. As well as the subject and caption, I upload the
original image, re-size it with AspJpeg to the main image size, put this in
the recordset and then re-size the image again to the thumbnail size and put
that in the recordset. I don't see how to do this using INSERT. If there
is a way, great. If there isn't, how do I get the correct Unicode
characters in the subject and caption fields into the table via a recordset
with Open, AddNew and Update?




Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Bob Barrows [MVP]
Guest
 
Posts: n/a
#9: Apr 7 '06

re: Inserting unicode characters into a database using RecordSet.Update


Roger Withnell wrote:[color=blue]
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:uLX6ZdkWGHA.4212@TK2MSFTNGP02.phx.gbl...[color=green]
>> Roger Withnell wrote:[color=darkred]
>>> I'd rather not change the code I have already.[/color]
>>
>> Even if the change results in a more efficient, better-performing
>> application?
>>
>> At the very least, since you are processing multiple records, you
>> should open your recordset using adLockOptimisticBatch for the lock
>> type, disconnect it (by setting the ActiveConnection property to
>> nothing and closing your connection), add your records using Update,
>> reconnect it (by opening the connection and setting the
>> ActiveConnection property to the opened connection object) and use
>> updateBatch to send the new records to the
>> database.
>>[color=darkred]
>>> Is it not possible to
>>> insert the correct Unicode characters into the table using
>>> Rs.Update?[/color]
>>
>> Of course it is. All I can do is repeat Anthony's question: have you
>> tried it?
>>
>> Bob Barrows
>> --
>> Microsoft MVP -- ASP/ASP.NET[/color]
>
> I am inserting one record, not multiple records. A record has a
> subject and a caption (both nvarchar), a thumbnail and a main image
> both created from the same original image file, using AspUpload and
> AspJpeg to upload and re-size the images. As well as the subject and
> caption, I upload the original image, re-size it with AspJpeg to the
> main image size, put this in the recordset and then re-size the image
> again to the thumbnail size and put that in the recordset.[/color]

All of this activity should take place before opening the recordset. The
goal is to stay connected to the database for as short a time as possible.
So do your resizing, etc. then open the connection and recordset and assign
the values to the fields. If that is not possible due to limitations of the
upload tool you are using, then use a disconnected recordset
[color=blue]
> I don't
> see how to do this using INSERT. If there is a way, great.[/color]

Yes, you would use a Command object to pass the data to a string containing
parameter markers

strsql = "INSERT (Subject,Caption,Thumb) VALUES (?,?,?)"
Const adVarWChar = 202
Const adLongVarBinary = 205
Const adParamInput = &H0001
Subj="xxxxxx"
Capt = "xxxxx xxx xxxxx"
SubjSize = 50 ' just a guess on my part
CaptSize = 200 ' again, just a guess - adjust if incorrect
set cmd=createobject("adodb.command")
with cmd
.commandtext=strsql
.commandtype=1 'adCmdText
set .ActiveConnection = conn
.Parameters.Append .CreateParameter("first",adVarWChar, _
Subjsize,adParamInput, Subj)
.Parameters.Append .CreateParameter("second",adVarWChar, _
Captsize,adParamInput, Capt)
.Parameters.Append .CreateParameter("third", _
adLongVarBinary, ,adParamInput, thumbnail)
.execute ,,128 'adExecuteNoRecords
end with

or better yet, a stored procedure, which would enable you to use my tool
available at
http://www.thrasherwebdesign.com/ind...s&hp=links.asp to generate
the command object parameter creation code.
[color=blue]
> If there
> isn't, how do I get the correct Unicode characters in the subject and
> caption fields into the table via a recordset with Open, AddNew and
> Update?[/color]

I'm sorry, but all I can say is: just do it. The code in your first post
should work. What is the issue?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Roger Withnell
Guest
 
Posts: n/a
#10: Apr 7 '06

re: Inserting unicode characters into a database using RecordSet.Update



"Anthony Jones" <Ant@yadayadayada.com> wrote in message
news:eVwS8fiWGHA.3660@TK2MSFTNGP04.phx.gbl...[color=blue]
>
> "Roger Withnell" <rogerREMOVE@THISupperbridge.co.uk> wrote in message
> news:1144348390_1125@sp6iad.superfeed.net...[color=green]
>> I'm using ASP, VBScript and SQL Server.
>>
>> I'm also using UTF-8 character set and so my codepage is 65001 and SQL
>> Server datatype nvarchar.
>>
>> I can insert unicode characters correctly into the database table using
>> INSERT.... (field1) ...VALUES ......... (N'Characters').
>>
>> How do I do this using Rs.Update viz-a-viz:
>>
>> Rs.Open .......
>> Rs.New
>> Rs("Field1") = "Characters"
>> Rs.Update
>>
>> Thanking you in anticipation.
>>
>>[/color]
>
> Have you tried it? Did it work?
> What do imagine you might need to change in the above to make it work?[/color]

Whoops! Didn't set Upload.CodePage = 65001 in AspUpload.
Sorry to waste your time.




Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Roger Withnell
Guest
 
Posts: n/a
#11: Apr 7 '06

re: Inserting unicode characters into a database using RecordSet.Update



"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:ObSHFmlWGHA.5096@TK2MSFTNGP03.phx.gbl...[color=blue]
> Roger Withnell wrote:[color=green]
>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>> news:uLX6ZdkWGHA.4212@TK2MSFTNGP02.phx.gbl...[color=darkred]
>>> Roger Withnell wrote:
>>>> I'd rather not change the code I have already.
>>>
>>> Even if the change results in a more efficient, better-performing
>>> application?
>>>
>>> At the very least, since you are processing multiple records, you
>>> should open your recordset using adLockOptimisticBatch for the lock
>>> type, disconnect it (by setting the ActiveConnection property to
>>> nothing and closing your connection), add your records using Update,
>>> reconnect it (by opening the connection and setting the
>>> ActiveConnection property to the opened connection object) and use
>>> updateBatch to send the new records to the
>>> database.
>>>
>>>> Is it not possible to
>>>> insert the correct Unicode characters into the table using
>>>> Rs.Update?
>>>
>>> Of course it is. All I can do is repeat Anthony's question: have you
>>> tried it?
>>>
>>> Bob Barrows
>>> --
>>> Microsoft MVP -- ASP/ASP.NET[/color]
>>
>> I am inserting one record, not multiple records. A record has a
>> subject and a caption (both nvarchar), a thumbnail and a main image
>> both created from the same original image file, using AspUpload and
>> AspJpeg to upload and re-size the images. As well as the subject and
>> caption, I upload the original image, re-size it with AspJpeg to the
>> main image size, put this in the recordset and then re-size the image
>> again to the thumbnail size and put that in the recordset.[/color]
>
> All of this activity should take place before opening the recordset. The
> goal is to stay connected to the database for as short a time as possible.
> So do your resizing, etc. then open the connection and recordset and
> assign
> the values to the fields. If that is not possible due to limitations of
> the
> upload tool you are using, then use a disconnected recordset
>[color=green]
>> I don't
>> see how to do this using INSERT. If there is a way, great.[/color]
>
> Yes, you would use a Command object to pass the data to a string
> containing
> parameter markers
>
> strsql = "INSERT (Subject,Caption,Thumb) VALUES (?,?,?)"
> Const adVarWChar = 202
> Const adLongVarBinary = 205
> Const adParamInput = &H0001
> Subj="xxxxxx"
> Capt = "xxxxx xxx xxxxx"
> SubjSize = 50 ' just a guess on my part
> CaptSize = 200 ' again, just a guess - adjust if incorrect
> set cmd=createobject("adodb.command")
> with cmd
> .commandtext=strsql
> .commandtype=1 'adCmdText
> set .ActiveConnection = conn
> .Parameters.Append .CreateParameter("first",adVarWChar, _
> Subjsize,adParamInput, Subj)
> .Parameters.Append .CreateParameter("second",adVarWChar, _
> Captsize,adParamInput, Capt)
> .Parameters.Append .CreateParameter("third", _
> adLongVarBinary, ,adParamInput, thumbnail)
> .execute ,,128 'adExecuteNoRecords
> end with
>
> or better yet, a stored procedure, which would enable you to use my tool
> available at
> http://www.thrasherwebdesign.com/ind...s&hp=links.asp to
> generate
> the command object parameter creation code.
>[color=green]
>> If there
>> isn't, how do I get the correct Unicode characters in the subject and
>> caption fields into the table via a recordset with Open, AddNew and
>> Update?[/color]
>
> I'm sorry, but all I can say is: just do it. The code in your first post
> should work. What is the issue?
>
> --
> Microsoft MVP -- ASP/ASP.NET
>[/color]

Whoops! Didn't set Upload.CodePage = 65001 in AspUpload.
Sorry to waste your time.



Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Closed Thread