Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Types using ADO

Status
Not open for further replies.

cyberbiker

Programmer
Joined
Mar 16, 2001
Messages
431
Location
US
Well, looks like I have another problem with the basics.
As I have said, I am converting an app from jet and ACCESS 97 to ADO and SQL Server (MSDE).

I am becoming confused on the different data types and constants. The following function currently exists:

Public Sub bsSizeToDb(fld As Field, size As Variant, Optional ByVal lcd As Boolean = True)
'--- Converts <size> (type Null or Double) to database field <fld>
If fld Is Nothing Then ERR.Raise 911, , &quot;Database doesn't contain size field&quot;
If IsNull(size) Or IsEmpty(size) Then
fld.value = Null
ElseIf VarType(size) <> vbDouble Then
GoTo badtype
Else
If bpDbMetric Then size = size * 25.4
Select Case fld.Type
'Case dbDouble, dbSingle, dbFloat, dbInteger, dbLong, dbDecimal, dbNumeric 'this line I commented out and replaced with the next line

Case adBigInt, adDouble, adInteger, adSingle, adSmallInt, adTinyInt, adDecimal, adNumeric 'this line is my best guess as to what I should do instead

fld.value = size

Case dbMemo
'What do I do with this??????
fld.value = bfLCDString(size, lcd)
Case dbChar, dbText

Dim maxlen As Long, txt As String
txt = bfLCDString(size, lcd And Not bpDbMetric)
maxlen = fld.size
If maxlen = 0 Then maxlen = 255
If Len(txt) > maxlen Then
'--- String doesn't fit in field, trimming works if not LCD
If bpDbMetric And lcd Then ERR.Raise 911, , &quot;Size doesn't fit in database field '&quot; & fld.name & &quot;'&quot;
txt = Left$(txt, maxlen)
End If
fld.value = txt
Case Else
GoTo badtype
End Select
End If
Exit Sub
badtype:
ERR.Raise 911, , &quot;Cannot convert size to database field '&quot; & fld.name & &quot;'&quot;
End Sub

When I read help and my books, it looks as if advarChar is the needed replacement for a memo field except that help says it is for parameters only.

When I converted the ACCESS tables, many of the text fields were converted as varChar. How can this be if the constant advarchar is only for parameters? Or what am I missing?

BTW, no &quot;memo&quot; field currently exists in the ACCESS 97 tables. This function is for a planned future change. So I do have some flexibility Terry (cyberbiker)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top