Solved

VB.NET - SQL Server

Posted on 2004-09-28
9
696 Views
Last Modified: 2012-06-27
Hi,

I have a few questions.

1. Does anyone know where I can find data type comparison chart between VB.NET and SQL Server data types.

2. I have a piece of code which uses a data reader to bring in a set a records, I loop through each record and assign it to a class then add the class to an array list. For each field I check it is not null, if it is not null I convert it to the relevant class property type.

The problem I have is this, when the field is a sql server timestamp or datetime can I use the System.Convert class to convert them or do I need something else?

The class properties are declared as follows

timestamp = object
datetime = date

0
Comment
Question by:rocky050371
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12170012
Do you have some relevant code to highlight what you are saying?

Bob
0
 
LVL 7

Accepted Solution

by:
natloz earned 43 total points
ID: 12170026
you can simply use

Dim dteDate as DateTime <--------- for the SQL DateTime

and I believe that SqlBinary is the datatype in VB.Net that is equivilant to timestamp
0
 

Assisted Solution

by:brunka
brunka earned 41 total points
ID: 12170971
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:rocky050371
ID: 12173335
Thank you for the link, but I am left with a decision to make, does anyone know where it is better to stick to SQL data types throughout the program, i.e declared in the class etc than use VB's own internal data types. For example if the data field is varchar in SQL Server is it better to assign it to a property whose data type is string or SQLString? Just wondering whether this will cause any problems while manipulating an array of classes or binding which is done higher up the architecture.




0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 41 total points
ID: 12173349
IMHO it is better to stick to data types that are base types, such as String, Integer, etc.  A lot of functions don't understand what an SQLString type is.

Bob
0
 
LVL 7

Expert Comment

by:natloz
ID: 12174205
I agree with Bob...I have had problems with SQLDataTypes in VB.Net...I generally only use the SQL datatypes when passing to stored procedures (at the time I pass to the stored proc I make sure it is in a compatible VB.Net datatype)...it will crash if it isn't!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
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…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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