首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VB与MySQL的连接

VB与MySQL的连接
EN

Stack Overflow用户
提问于 2010-01-18 15:03:19
回答 3查看 5.7K关注 0票数 0

我想请教一下如何将VB6连接到MYSQL?请同时提供参考资料。

非常感谢

EN

回答 3

Stack Overflow用户

发布于 2010-01-18 20:09:45

谷歌表示,你可以使用ADOMySQL ODBC驱动程序。

代码语言:javascript
复制
Dim strConnection$, conn As Connection 

'Fill in the placeholders with your server details'
strConnection = "Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;" & _ 
   "Database=myDataBase;User=myUsername;Password=myPassword;Option=3"

Set conn = New Connection  
conn.Open strConnection

来自here的MySQL的ODBC连接字符串。

警告:air code。我自己从来没有做过这件事。

票数 2
EN

Stack Overflow用户

发布于 2010-01-18 15:36:53

链接:http://paulbradley.tv/37/

这段代码演示了如何从用Visual basic6编写的基于Windows的应用程序连接到MySQL数据库。通过使用Microsoft驱动程序和MySQL远程数据对象,从MySQL数据库服务器连接和检索记录非常容易。

下载并安装MySQL ODBC驱动程序。

-设置允许从任何主机进行连接的MySQL用户名和密码组合。请参见MySQLs命令。

启动一个新的Visual Basic项目并添加Microsoft远程数据对象-使用菜单选择project | References,然后从列表中选择Microsoft Remote数据对象。

示例代码

代码语言:javascript
复制
Private Sub cmdConnectMySQL_Click()

Dim cnMySql As New rdoConnection
Dim rdoQry  As New rdoQuery
Dim rdoRS   As rdoResultset

' set up a remote data connection
' using the MySQL ODBC driver.
' change the connect string with your username,
' password, server name and the database you
' wish to connect to.

cnMySql.CursorDriver = rdUseOdbc
cnMySql.Connect = "uid=YourUserName;pwd=YourPassword;
    server=YourServerName;" & _
    "driver={MySQL ODBC 3.51 Driver};
    database=YourDataBase;dsn=;"
cnMySql.EstablishConnection

' set up a remote data object query
' specifying the SQL statement to run.

With rdoQry
    .Name = "selectUsers"
    .SQL = "select * from user"
    .RowsetSize = 1
    Set .ActiveConnection = cnMySql
    Set rdoRS = .OpenResultset(
            rdOpenKeyset, rdConcurRowVer)
End With

' loop through the record set
' processing the records and fields.

Do Until rdoRS.EOF
    With rdoRS

    ' your code to process the fields
    ' to access a field called username you would
    ' reference it like !username

        rdoRS.MoveNext
    End With
Loop

' close record set
' close connection to the database

rdoRS.Close
cnMySql.Close

End Sub
票数 0
EN

Stack Overflow用户

发布于 2020-01-08 04:51:37

代码语言:javascript
复制
#include <iostream>
#include <sstream>

#include <cpr/cpr.h>
#include <elmo.hpp>

void appInit(char *args) {

}

int main(int argc, char *argv) {

if (argc > 1) {
    appInit(argv);
} else {
    std::cout << "Usage: a.out [search keyword]" << std::endl;
}

int limit = 3;

cpr::Parameters parameters{{"query", input},
                    {"limit", "3"},
                    {"indent", "true"},
                    {"key", "AIzaSyA5Xr82w7LrJgaLPb99P4kVZzFlxYuPhng"}};

auto response = cpr::Get(cpr::Url{
    "https://kgsearch.googleapis.com/v1/entities:search"}, parameters);

auto elmo = nlohmann::elmo::parse(response.text);
elmo.flatten();

for (int i=0; i<limit; i++) {
    std::ostringstream oss;
    std::cout << elmo["/itemListElement/0/result/name"_elmo_pointer];
    //std::cout << elmo["/itemListElement/i/result/@type/0"_elmo_pointer] << std::endl;
    //std::cout << elmo["/itemListElement/i/result/@type/1"_elmo_pointer] << std::endl;
    std::cout << elmo["/itemListElement/0/result/description"_elmo_pointer] << std::endl;
    std::cout << elmo["/itemListElement/0/result/detailedDescription/articleBody"_elmo_pointer] << std::endl;
    std::cout << elmo["/itemListElement/0/result/image/url"_elmo_pointer] << std::endl;
}

//std::cout << json.dump(4) << std::endl;
}
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2084376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档