By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,312 Members | 2,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,312 IT Pros & Developers. It's quick & easy.

Inserting unicode characters into a database using RecordSet.Update

P: n/a
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.
Apr 6 '06 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Roger Withnell wrote:
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').
Since you can do it this way ...
How do I do this using Rs.Update viz-a-viz:

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.
Apr 6 '06 #2

P: n/a

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:uq*************@TK2MSFTNGP05.phx.gbl...
Roger Withnell wrote:
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').

Since you can do it this way ...
How do I do this using Rs.Update viz-a-viz:

why would you ever want to use a recordset for updating data in an asp
application?


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

P: n/a
Roger Withnell wrote:
why would you ever want to use a recordset for updating data
in an asp application?


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


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.
Apr 6 '06 #4

P: n/a

"Dave Anderson" <GT**********@spammotel.com> wrote in message
news:eE**************@TK2MSFTNGP02.phx.gbl...
Roger Withnell wrote:
why would you ever want to use a recordset for updating data
in an asp application?


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


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.


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?
Apr 6 '06 #5

P: n/a

"Roger Withnell" <ro*********@THISupperbridge.co.uk> wrote in message
news:11*************@sp6iad.superfeed.net...
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.


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


Apr 7 '06 #6

P: n/a
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
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.
Apr 7 '06 #7

P: n/a

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:uL**************@TK2MSFTNGP02.phx.gbl...
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


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
Apr 7 '06 #8

P: n/a
Roger Withnell wrote:
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:uL**************@TK2MSFTNGP02.phx.gbl...
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


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.


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
I don't
see how to do this using INSERT. If there is a way, great.
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.
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?


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.
Apr 7 '06 #9

P: n/a

"Anthony Jones" <An*@yadayadayada.com> wrote in message
news:eV**************@TK2MSFTNGP04.phx.gbl...

"Roger Withnell" <ro*********@THISupperbridge.co.uk> wrote in message
news:11*************@sp6iad.superfeed.net...
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.


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


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
Apr 7 '06 #10

P: n/a

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:Ob**************@TK2MSFTNGP03.phx.gbl...
Roger Withnell wrote:
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:uL**************@TK2MSFTNGP02.phx.gbl...
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


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.


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
I don't
see how to do this using INSERT. If there is a way, great.


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.
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?


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


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
Apr 7 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.