954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

DataCombo Connection problem

I want to show record list in Datacombo through coding , using SQL Server 2000,VB6.

Following are the coding.

********************************
Private Sub Form_Load()

Dim CNN As New ADODB.Connection
Dim RST As New ADODB.Recordset

Set CNN = New ADODB.Connection
CNN.Provider = "SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Maintenance;Data Source=YASIR"
CNN.Open

Set RST = New ADODB.Recordset

RST.Open "SELECT * FROM MAINT", CNN, adOpenKeyset, adLockOptimistic

Set DataCombo1.RowSource = RST
DataCombo1.ListField = Mill
Text1 = RST!Mill

End Sub

********************************
Text1(textbox) is showing record it means dataconnection is established. but no record showing in Datacombo. Please help .one thing more that if I use Ms Access Database then record is showing Datacombo,(just chaning on cnn.provider....)

Thanks
Yasir Farid

yasirfarid
Newbie Poster
7 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Please check up whether after placing the period(dot) after DataCombo1 the methods RowSourse and ListFields are poping up.
If they are, please get back to me.

Yor connection strings are having some problem that I will tell you.

AV Manoharan
Junior Poster
166 posts since Jun 2007
Reputation Points: 10
Solved Threads: 9
 

Hi Yasir,

Check This :

Set DataCombo1.RowSource = RST DataCombo1.ListField= "Mill"

Wrap Mill with double Quotes ( " )

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 
Please check up whether after placing the period(dot) after DataCombo1 the methods RowSourse and ListFields are poping up. If they are, please get back to me. Yor connection strings are having some problem that I will tell you.

yes after placing the period (dof) Rowsource and Listfields are popping up.

yasirfarid
Newbie Poster
7 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Veena
Yes I have done, but still not working...

Yasir

Hi Yasir, Check This : Set DataCombo1.RowSource = RST DataCombo1.ListField= "Mill"

Wrap Mill with double Quotes ( " ) Regards Veena

yasirfarid
Newbie Poster
7 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Hi Yasir,
Open Recordset this way :

Set RST = New ADODB.Recordset
RST.CursorLocation = adUseClient
RST.Open "SELECT * FROM MAINT", CNN, adOpenKeyset, adLockOptimistic


After filling, it dosent show on the Combo's Text, To Check Click on then DropDown Arrow of the Combo, It will be filled,

REgards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

Hi,

If still that did not work then
Open recordset this way :(Static / Read Only)

RST.Open "SELECT * FROM MAINT", CNN, adOpenStatic, adLockReadOnly

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 
I want to show record list in Datacombo through coding , using SQL Server 2000,VB6. Following are the coding. ******************************** Private Sub Form_Load() Dim CNN As New ADODB.Connection Dim RST As New ADODB.Recordset Set CNN = New ADODB.Connection 'Please avoid the above underlined One CNN.Provider = "SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Maintenance;Data Source=YASIR" 'Change all those underlined above as below CNN.ConnectionString="Provider=SQLOLEDB.1;UID=sa;PWD=sa;Data Sourse=YASIR;Initial Catalog=Maintenance" 'If the UserID & Password are not 'sa' please change it accordingly. CNN.Open Set RST = New ADODB.Recordset 'Instead of above line please give as below RST.ActiveConnection = CNN If RST.State = adStateOpen then RST.Close End If RST.Open "SELECT * FROM MAINT", CNN, adOpenKeyset, adLockOptimistic 'See that the table above underlined exist in the database Maintenance. Set DataCombo1.RowSource = RST DataCombo1.ListField = Mill Text1 = RST!Mill If RST.State = adStateOpen then RST.Close End If End Sub ******************************** Text1(textbox) is showing record it means dataconnection is established. but no record showing in Datacombo. Please help .one thing more that if I use Ms Access Database then record is showing Datacombo,(just chaning on cnn.provider....) Thanks Yasir Farid



Yasir, I have underlined the code that you have to change or replace
then run it and get back to me.

AV Manoharan

AV Manoharan
Junior Poster
166 posts since Jun 2007
Reputation Points: 10
Solved Threads: 9
 

Yes Veena Thank you,

After applying RST.CursorLocation = adUseClient, its shows records on datacombo..Thanks again.

meet you soon with other trouble.;)

Yasir

yasirfarid
Newbie Poster
7 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Veena, you your aptitude is to be appreciated, even i had the same problem. from access, data coming in db combo, but not from sql...how can we guess, there is something wrong in the code, (in the way, data is picked up from sql...)

thanks a lot...

Rajeev3010
Newbie Poster
1 post since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You