Improve company productivity with a Business Account.Sign Up

x
?
Solved

Database string lengths

Posted on 2006-12-01
10
Medium Priority
?
286 Views
Last Modified: 2010-04-23
Hi

I have an Access database in which all of the strings are stored with a length of 255.
Is there an easy way to either store the trimmed strings or, when filling a dataset, only fill the trimmed strings.
I cannot specify the string length as that is unknown and will vary.
All help  appreciated.

Regards
0
Comment
Question by:alungwyther
  • 5
  • 4
10 Comments
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18059756
There are a couple things you can do. The first (and best, IMO) is to migrate to SQL Express and use varchar(255) fields to migrate. This will keep your data intact, but empty space has no storage allocated.

The second option is to write your Access query using Trim([fieldname]) to trim leading and trailing spaces. As a side note, I don't think that the OleDbAdapter brings in the extra strings; that's a database-interal issue that should be hidden.

If you insist on using Access, however, every record will use 255 characters worth or storage for the field, whether there is anything in it or not -- this is a limitation of Access, not VB .NET.
0
 
LVL 10

Expert Comment

by:gangwisch
ID: 18059762
you can put partial strings together when calling a dataset
for example:
firstname    lastname
======    ======
bill              campbell
lucy            somaro

select (ltrim(firstname) + ' ' + ltrim(lastname)) as fullname

fullname
=====
bill campbell
lucy somaro

you can also set the field type to be text to make it as long as you want
0
 

Author Comment

by:alungwyther
ID: 18059983
Hi Chaosian

Thanks for the reply.
Do you know of any good resources on the web to get me started with SQL Express.
I have only just started with Access databases so I need real beginners stuff.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:alungwyther
ID: 18059988
Hi gangwisch

Thanks for the reply but its not what I was looking for.
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18059989
Let me see what I can find for you. How solid is your database design background?
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18059997
Here's the link to the SQL Express download: http://msdn.microsoft.com/vstudio/express/sql/register/default.aspx

One of the nice things is that it is completed integrated into Visual Studio. Depending on what version you have, you can actually design your database tables and queries from your VS IDE.
http://msdn.microsoft.com/vstudio/express/sql/
0
 

Author Comment

by:alungwyther
ID: 18060019
Hi Chaosian

Thanks for the links.
My database design background is pretty much zero, just picking it upas I go along.
0
 
LVL 24

Accepted Solution

by:
Jeff Certain earned 500 total points
ID: 18060028
Okay... tough spot to be in -- been there myself. The best thing you can do is pick up a good book on databases. Not at the office, so I can't tell you what I used... it was a SQL Server 2000 DBA book with a sailboat on the front LOL

Here's a link to a reasonable resource (at least from a quick scan): http://www.edm2.com/0612/msql7.html

Basic gist of it is this:
1. If you have repetitive data, you need to use a lookup table.
2. If you can't fit your table on one screen, you've done something wrong.
3. Never, ever use Access if you can avoid it :)
0
 

Author Comment

by:alungwyther
ID: 18060036
Hi Chaosian

Many thanksfor yourhelp
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 18060052
Glad to help :)

As I'm sure you know, there are lots of us willing to help you get through this. In particular, database questions posted in the SQL topic area will get picked up by folks like Angel III, who has been great a great resource for me over the past couple years. (Probably a good reason he has 11 million EE points LOL)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Article by: Jorge
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Watch the working video to know how to import Outlook PST/OST files to Amazon WorkMail. Kernel released this tool which is very easy to use and migrate single or multiple PST and OST files to Amazon WorkMail. To know more about Kernel Import PST to …

606 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question