Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.NET - SQL Server

Posted on 2004-09-28
9
Medium Priority
?
705 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
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 172 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 164 total points
ID: 12170971
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 164 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

916 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