|
-
August 8th, 2008, 01:22 AM
#8
Re: HELP with SQL and strings
You didn't say which SQL Server, but you can use this with MS SQL Server.
have to translate from VB6
Code:
Option Explicit
Private Sub Form_Load()
Dim strsql$, strlength$
Dim strFeet$, strInch$
strFeet = "10"
strInch = "11"
strlength = strFeet & "'" & "x" & strInch & Chr(34)
strsql = "INSERT items values('Board', '" & CleanText(strlength) & "')"
MsgBox strsql
Debug.Print strsql
End Sub
Public Function CleanText(strIn As String) As String
On Error GoTo VBError
Dim iAcnt As Long
Dim strString As String
Dim vLimit As Long
vLimit = Len(strIn)
For iAcnt = 1 To vLimit
Select Case Asc(Mid$(strIn, iAcnt, 1))
Case 10, 13
strString = strString & Mid$(strIn, iAcnt, 1)
Case 124
strString = strString & "!"
Case 39
strString = strString & "''"
Case 34
strString = strString & """"
Case Is < 32
strString = strString & " "
Case Is > 126
strString = strString & " "
Case Else
strString = strString & Mid$(strIn, iAcnt, 1)
End Select
Next
CleanText = strString
Exit Function
VBError:
MsgBox "VBError in Sub Parse_SQL_Text : " & Err.Number & " - " & Err.Description
Resume Next
End Function
Last edited by dglienna; August 8th, 2008 at 01:43 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|