If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > method or data member not found

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-20-09, 03:43
ichi lee ichi lee is offline
Registered User
 
Join Date: Nov 2009
Posts: 1
method or data member not found

I using vb 6.0 and microsoft sql server studio express.
What i wanna do is populate data field name ItemType from database name AMS with table name ItemType into visual basic 6.0 combo box. The problem i facing is "method or data member not found" which point to .addItem.

Is it i using wrong way to call ComboItemType or i done something wrong on my connection.
Anybody know how to solve this problem, please help me.

Thanks.


Code:
Private Sub Form_Load()

Set conn = New ADODB.connection
conn.Provider = "sqloledb"
conn.Properties("Data Source").Value = "IT\SQLEXPRESS"
conn.Properties("User Id").Value = "sa"
conn.Properties("Password").Value = "123"
conn.Properties("Initial Catalog").Value = "AMS"
conn.Properties("Integrated Security").Value = "SSPI"

conn.Open

Dim sql As String
sql = "Select ItemType from ItemType"
Set rs = conn.Execute(sql, , adCmdText)

With ComboItemType

Do Until rs.EOF
.AddItem rs.Fields("ItemType").Value

rs.MoveNext
Loop
End With

rs.Close
conn.Close
Set rs = Nothing

End Sub
edit by loquin: added [code]...[/code] tags for readability... Try it - you'll like it.

Last edited by loquin; 12-02-09 at 18:42. Reason: added [code]...[/code] tags for readability... Try it - you'll like it.
Reply With Quote
  #2 (permalink)  
Old 11-23-09, 08:14
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
What is ComboItemType? A control? Can you access any of this objects properties?

Moving to Visual Basic topic as I do not feel that this has anything to do with the SQL side of things
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 11-23-09, 09:17
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
Add a breakpoint and figure out if it's the .AddItem method that's creating the problem, or if it can't find ItemType in the rs.Fields() collection.
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On