Jump to content

how to write only a few characters of a field


netcracker

Recommended Posts

does anyone know how to write only a part of a filed ? say... the first 10 characters!let's say i select a record from a db and i want to write the begining of a fieldthis would write the whole contents of that field..

    response.write(rs.fields.item("field"))

..but what if i want to write only the first 10 letters ??i think it shouyld be something like this:

    response.write(rs.fields.item("descriere_scurta").Read(5))

...but it's not.please help !thx

Link to comment
Share on other sites

Maybe you need the Left(string, number) functionThis example below would return ABC from the alphabet.

dim alphabet                                                                                     alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"                                                   response.write "<p>The first three characters of the alphabet are: " & left(alphabet,3) & "</p>"

Link to comment
Share on other sites

This might work, i havent tested it cause i don't have access to asp just now.

response.write left((rs.fields.item("field")),10)

Link to comment
Share on other sites

Just as a note, you should use rs.fields.item("field").value. Don't forget the .value at the end. You will get the value most of the time if you leave off .value, but saying rs.fields.item("field") is a reference to the item object itself, not the value of it. If you are doing comparisons against literal values, you will run into problems comparing an object with a literal.

Link to comment
Share on other sites

What is that??? Please don't spam!
Just as a note, you should use rs.fields.item("field").value. Don't forget the .value at the end. You will get the value most of the time if you leave off .value, but saying rs.fields.item("field") is a reference to the item object itself, not the value of it. If you are doing comparisons against literal values, you will run into problems comparing an object with a literal.
Oh...how many times have I been there, lol.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...