|
-
Jun 3rd, 2005, 02:30 PM
#1
Thread Starter
Member
combo box nightmares
hi
I have a combo box that pulls the data from a look up table present in the SQL server.
I am getting this weird error
"string or binary data would be truncated"
This only happens when the drop down list has strings like
"voice_and_data"
"handset_in_closet"
Can some one please help
The code is
Private Sub load_cmbMbl()
Dim conSQL As ADODB.Connection
'Sets connection
Set conSQL = New ADODB.Connection
Dim strSQLServer As String
Dim strSQLDatabaseToOpen As String
Dim strConnectString As String
Dim strSQL2 As String
strSQLServer = "sfdaqsql1"
strSQLDatabaseToOpen = "techlog_copy"
strConnectString = "Provider=sqloledb;" & _
"Integrated Security=SSPI;" & _
"Data Source=" & strSQLServer & ";" & _
"Initial Catalog=" & strSQLDatabaseToOpen & ";"
conSQL.Open (strConnectString)
cmbMbl.Clear
Dim rsRecords As ADODB.Recordset
Set rsRecords = New ADODB.Recordset
strSQL2 = "SELECT mobile_test FROM Mobile_Test_Lookup"
rsRecords.Open strSQL2, conSQL
If Not (rsRecords.BOF And rsRecords.EOF) Then
rsRecords.MoveFirst
Do
cmbMbl.AddItem rsRecords.Fields
rsRecords.MoveNext
Loop Until rsRecords.EOF
End If
rsRecords.Close
Set rsRecords = Nothing
conSQL.Close
End Sub
Please help
-
Jun 3rd, 2005, 02:43 PM
#2
Junior Member
Re: combo box nightmares
You ommitted the field name to use to add to the combobox :
Do
cmbMbl.AddItem rsRecords.Fields
rsRecords.MoveNext
should be:
Do
cmbMbl.AddItem rsRecords.Fields("fieldname")
rsRecords.MoveNext
Hope that helps
-
Jun 3rd, 2005, 04:42 PM
#3
Thread Starter
Member
Re: combo box nightmares
I am still getting the same errror.
Dim rsRecords As ADODB.Recordset
Set rsRecords = New ADODB.Recordset
strSQL2 = "SELECT status FROM Status_Lookup"
rsRecords.Open strSQL2, conSQL
If Not (rsRecords.BOF And rsRecords.EOF) Then
rsRecords.MoveFirst
Do
cmbStatus.AddItem rsRecords.Fields("Status").Value
rsRecords.MoveNext
Loop Until rsRecords.EOF
End If
rsRecords.Close
-
Jun 3rd, 2005, 06:29 PM
#4
Re: combo box nightmares
hi
I have a combo box that pulls the data from a look up table present in the SQL server.
I am getting this weird error
" string or binary data would be truncated"
is this the line that the error is generated?
VB Code:
cmbStatus.AddItem rsRecords.Fields("Status").Value
if so, what is the value of rsRecords.Fields("Status").Value?
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Jun 3rd, 2005, 06:32 PM
#5
Re: combo box nightmares
I would just use the field number
Which would be the first field returned from your database
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
|