473,385 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with codes

4
Hello. I'm trying to link my Microsoft Access 2003 database to my VB Combobox. I want to get my combobox's list directly from my database so that everytime my database is changed (e.g: added new names or deleted a name), the combobox will be updated automatically.

I tried using
Dim conec As New ADODB.Connection
Dim rs As New ADODB.Recordset
rs.Open "select STUDENTNAME from STUDENTDATA", conec, adOpenKeyset, adLockOptimistic
If rs1.EOF = False Then
Do Until rs1.EOF
Combo1.AddItem rs!KD_SALES
rs.MoveNext
Loop
rs.Close
End If
End Sub


but they arn't working and thus i connected my program using

Dim conec AS New OleDB.OleDBConnection
conec.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = Actual_Database.mdb; Jet OLEDB:Database Password = xxxx"
con.Open( )
con.Close( )


Right now i'm stuck at this point. I'm having problems getting my combobox's list directly from my database. When i tried putting the ADODB.RecordSet, blue wriggly lines appear. Any help would be greatly appreciated.

Cheers,
sowms
Jul 4 '07 #1
4 984
Hello. I'm trying to link my Microsoft Access 2003 database to my VB Combobox. I want to get my combobox's list directly from my database so that everytime my database is changed (e.g: added new names or deleted a name), the combobox will be updated automatically.

I tried using
Dim conec As New ADODB.Connection
Dim rs As New ADODB.Recordset
rs.Open "select STUDENTNAME from STUDENTDATA", conec, adOpenKeyset, adLockOptimistic
If rs1.EOF = False Then
Do Until rs1.EOF
Combo1.AddItem rs!KD_SALES
rs.MoveNext
Loop
rs.Close
End If
End Sub


but they arn't working and thus i connected my program using

Dim conec AS New OleDB.OleDBConnection
conec.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = Actual_Database.mdb; Jet OLEDB:Database Password = xxxx"
con.Open( )
con.Close( )


Right now i'm stuck at this point. I'm having problems getting my combobox's list directly from my database. When i tried putting the ADODB.RecordSet, blue wriggly lines appear. Any help would be greatly appreciated.

Cheers,
sowms

try this:

dim conec as adodb.connection
dim rs as adodb.recordset
dim SQL as string

SQL = ""select STUDENTNAME from STUDENTDATA"
set rs = conec.execute(SQL)

do while not rs.eof
me.combo1.addItem rs!STUDENTNAME
rs.movenext
loop



...hope it will work for you!
Jul 4 '07 #2
Killer42
8,435 Expert 8TB
By the way, what VB version are you using?
Jul 4 '07 #3
sowms
4
By the way, what VB version are you using?
I'm using Visual Studio 2005. I've already managed to solve the problem. Thanku.
Jul 6 '07 #4
Killer42
8,435 Expert 8TB
I'm using Visual Studio 2005. I've already managed to solve the problem. Thanku.
Ok. Glad to hear you;ve sorted it out.
Jul 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: N4M | last post by:
Dear, I have codes as follows: template<class T> class A { public: // embedded class class E; public: // types typedef E TE; public:// member functions TE somefunc();
10
by: dof | last post by:
I'm trying the following and having problems. I get errors on the array declaration lines. Something about an array must have at least one element. Thanks in advance. D #include stuff .... ...
2
by: Ecohouse | last post by:
I'm creating a query with a where statement using VBA to create a DAO recordset. I've separated the query to make it easier to read. This is the query: SELECT .Race, Count(.Race) AS...
0
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
16
by: Hooyoo | last post by:
Following are similar codes of my project: At first I define two classes in two files: //ClassA.h #pragma once #include "ClassB.h" class ClassA { public: ClassA(void){};
12
by: Light | last post by:
Hi all, I posted this question in the sqlserver.newusers group but I am not getting any response there so I am going to try it on the fine folks here:). I inherited some legacy ASP codes in my...
2
by: PoN | last post by:
Hello everyone.. i have to write codes in VB to solve the travelling salesman problem but i dun know how to start. So if ANYONE knows the codes, pls post it here. Or if there is a previous post on...
2
by: darrel | last post by:
Hi there vb masters i have a problem regrading the saving procedure in my program: Here my code: Private Sub cmdSave_Click() Dim rsShowRec As New ADODB.Recordset Dim cnn As New...
17
by: may bailey | last post by:
Hi all, I have been trying to use a show / hide script on my web site but when I click on the "hide" button there occurs an error with explorer 7. The web site starts to go down =) and there...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.