当前位置:首页 » 密码管理 » c数据库访问类

c数据库访问类

发布时间: 2022-04-02 00:10:57

c语言应该调用什么数据库 怎么调用

现在谁还有C啊,除非嵌入式编程

C++还差不多,如果是C++ 又是 Windows系统哪么通过ODBC是啥数据库都可以支持的

如果是Linux我就不太熟悉了,但至少也会有类于ODBC之类的数据库引擎

调用对编译器有要求吗---肯定没要求,要不然这个编译器就没存在必要,或者这个数据库接口就没做的通用化。

❷ 用C语言怎么实现与数据库的连接

#include<mysql/mysql.h>

#include<stdio.h>

intmain()

{

MYSQL*conn;

MYSQL_RES*res;

MYSQL_ROWrow;

char*server="localhost";//本地连接

char*user="root";//

char*password="525215980";//mysql密码

char*database="student";//数据库名

char*query="select*fromclass";//需要查询的语句

intt,r;

conn=mysql_init(NULL);

if(!mysql_real_connect(conn,server,user,password,database,0,NULL,0))

{

printf("Errorconnectingtodatabase:%s ",mysql_error(conn));

}else{

printf("Connected... ");

}

t=mysql_query(conn,query);

if(t)

{

printf("Errormakingquery:%s ",mysql_error(conn));

}else{

printf("Querymade... ");

res=mysql_use_result(conn);

if(res)

{

while((row=mysql_fetch_row(res))!=NULL)

{

//printf("num=%d ",mysql_num_fields(res));//列数

for(t=0;t<mysql_num_fields(res);t++)

printf("%8s",row[t]);

printf(" ");

}

}

mysql_free_result(res);

}

mysql_close(conn);

return0;

}

(2)c数据库访问类扩展阅读

C语言使用注意事项:

1、指针是c语言的灵魂,一定要灵活的使用它:

(1)、指针的声明,创建,赋值,销毁等

(2)、指针的类型转换,传参,回调等

2、递归调用也会经常用到:

(1)、递归遍历树结构

(2)、递归搜索

❸ c语言访问oracle数据库有几种方式,哪种最好

SQL SERVER连接oracle数据库几种方法--1 方式 --查询oracle数据库中的表 SELECT * FROM OPENDATASOURCE( 'MSDAORA', 'Data Source=GE160;User ID=DAIMIN;Password=DAIMIN' )..

❹ 实例讲解如何使用C++操作MySQL数据库类

/* * project: * 通用模块 ( 用 c++ 处理 mysql 数据库类,像ADO ) * * description: * * 通过DataBase,RecordSet,Record,Field类,实现对mysql数据库的操作 * 包括连接、修改、添加、删除、查询等等,像ADO一样操作数据库,使 * 用方便 * * ( the end of this file have one sample, * welcom to use... ) * * * file:zlb_mysql.h * * author: @ zlb * * time:2005-12-12 * * * --*/ #ifndef ZLB_MYSQL_H #define ZLB_MYSQL_H #include "mysql.h" #include <iostream> #include <vector> #include <string> using namespace std; namespace zlb_mysql{ /* * 字段操作 */ class Field { public : /* 字段名称 */ vector<string> m_name; /* 字段类型 */ vector<enum_field_types> m_type; public : Field(); ~Field(); /* 是否是数字 */ bool IsNum(int num); /* 是否是数字 */ bool IsNum(string num); /* 是否是日期 */ bool IsDate(int num); /* 是否是日期 */ bool IsDate(string num); /* 是否是字符 */ bool IsChar(int num); /* 是否是字符 */ bool IsChar(string num); /* 是否为二进制数据 */ bool IsBlob(int num); /* 是否为二进制数据 */ bool IsBlob(string num); /* 得到指定字段的序号 */ int GetField_NO(string field_name); }; /* * 1 单条记录 * 2 [int ]操作 [""]操作 */ class Record { public: /* 结果集 */ vector<string> m_rs; /* 字段信息 占用4字节的内存 当记录数很大是回产生性能问题 */ Field *m_field; public : Record(){}; Record(Field* m_f); ~Record(); void SetData(string value); /* [""]操作 */ string operator[](string s); string operator[](int num); /* null值判断 */ bool IsNull(int num); bool IsNull(string s); /* 用 value tab value 的形式 返回结果 */ string GetTabText(); }; /* * 1 记录集合 * 2 [int ]操作 [""]操作 * 3 表结构操作 * 4 数据的插入修改 */ class RecordSet { private : /* 记录集 */ vector<Record> m_s; /* 游标位置*/ unsigned long pos; /* 记录数 */ int m_recordcount; /* 字段数 */ int m_field_num; /* 字段信息 */ Field m_field; MYSQL_RES * res ; MYSQL_FIELD * fd ; MYSQL_ROW row; MYSQL* m_Data ; public : RecordSet(); RecordSet(MYSQL *hSQL); ~RecordSet(); /* 处理返回多行的查询,返回影响的行数 */ int ExecuteSQL(const char *SQL); /* 得到记录数目 */ int GetRecordCount(); /* 得到字段数目 */ int GetFieldNum(); /* 向下移动游标 */ long MoveNext(); /* 移动游标 */ long Move(long length); /* 移动游标到开始位置 */ bool MoveFirst(); /* 移动游标到结束位置 */ bool MoveLast(); /* 获取当前游标位置 */ unsigned long GetCurrentPos()const; /* 获取当前游标的对应字段数据 */ bool GetCurrentFieldValue(const char * sFieldName,char *sValue); bool GetCurrentFieldValue(const int iFieldNum,char *sValue); /* 获取游标的对应字段数据 */ bool GetFieldValue(long index,const char * sFieldName,char *sValue); bool GetFieldValue(long index,int iFieldNum,char *sValue); /* 是否到达游标尾部 */ bool IsEof(); /* 返回字段 */ Field* GetField(); /* 返回字段名 */ const char * GetFieldName(int iNum); /* 返回字段类型 */ const int GetFieldType(char * sName); const int GetFieldType(int iNum); /* 返回指定序号的记录 */ Record operator[](int num); }; /* * 1 负责数据库的连接关闭 * 2 执行sql 语句(不返回结果) * 3 处理事务 */ class DataBase { public : DataBase(); ~DataBase(); private : /* msyql 连接句柄 */ MYSQL* m_Data; public : /* 返回句柄 */ MYSQL * GetMysql(); /* 连接数据库 */ int Connect(string host, string user, string passwd, string db, unsigned int port, unsigned long client_flag); /* 关闭数据库连接 */ void DisConnect(); /* 执行非返回结果查询 */ int ExecQuery(string sql); /* 测试mysql服务器是否存活 */ int Ping(); /* 关闭mysql 服务器 */ int ShutDown(); /* 主要功能:重新启动mysql 服务器 */ int ReBoot(); /* * 说明:事务支持InnoDB or BDB表类型 */ /* 主要功能:开始事务 */ int Start_Transaction(); /* 主要功能:提交事务 */ int Commit(); /* 主要功能:回滚事务 */ int Rollback(); /* 得到客户信息 */ const char * Get_client_info(); /* 主要功能:得到客户版本信息 */ const unsigned long Get_client_version(); /* 主要功能:得到主机信息 */ const char * Get_host_info(); /* 主要功能:得到服务器信息 */ const char * Get_server_info(); /*主要功能:得到服务器版本信息*/ const unsigned long Get_server_version(); /*主要功能:得到 当前连接的默认字符集*/ const char * Get_character_set_name(); /* 主要功能返回单值查询 */ char * ExecQueryGetSingValue(string sql); /* 得到系统时间 */ const char * GetSysTime(); /* 建立新数据库 */ int Create_db(string name); /* 删除制定的数据库*/ int Drop_db(string name); }; }; #endif //ZLB_MYSQL_H /* * project: * 通用模块 ( 用 c++ 处理 mysql 数据库类,像ADO ) * * description: * * 通过DataBase,RecordSet,Record,Field类,实现对mysql数据库的操作 * 包括连接、修改、添加、删除、查询等等,像ADO一样操作数据库,使 * 用方便 * * ( the end of this file have one sample, * welcom to use... ) * * * file:zlb_mysql.cpp * * author: @ zlb * * time:2005-12-12 * * * --*/ #include "stdafx.h" #include "zlb_mysql.h" namespace zlb_mysql{ /* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ /* * 字段操作 */ Field::Field(){} Field::~Field(){} /* * 是否是数字 */ bool Field::IsNum(int num) { if(IS_NUM(m_type[num])) return true; else return false; } /* * 是否是数字 */ bool Field::IsNum(string num) { if(IS_NUM(m_type[GetField_NO(num)])) return true; else return false; } /* * 是否是日期 */ bool Field::IsDate(int num) { if( FIELD_TYPE_DATE == m_type[num] || FIELD_TYPE_DATETIME == m_type[num] ) return true; else return false; } /* 是否是日期 */ bool Field::IsDate(string num) { int temp; temp=GetField_NO(num); if(FIELD_TYPE_DATE == m_type[temp] || FIELD_TYPE_DATETIME == m_type[temp] ) return true; else return false; } /* * 是否是字符 */ bool Field::IsChar(int num) { if(m_type[num]==FIELD_TYPE_STRING || m_type[num]==FIELD_TYPE_VAR_STRING || m_type[num]==FIELD_TYPE_CHAR ) return true; else return false; } /* * 是否是字符 */ bool Field::IsChar(string num) { int temp; temp=this->GetField_NO (num); if(m_type[temp]==FIELD_TYPE_STRING || m_type[temp]==FIELD_TYPE_VAR_STRING || m_type[temp]==FIELD_TYPE_CHAR ) return true; else return false; } /* * 是否为二进制数据 */ bool Field::IsBlob(int num) { if(IS_BLOB(m_type[num])) return true; else return false; } /* * 是否为二进制数据 */ bool Field::IsBlob(string num) { if(IS_BLOB(m_type[GetField_NO(num)])) return true; else return false; } /* * 得到指定字段的序号 */ int Field::GetField_NO(string field_name) { for(unsigned int i=0;i<m_name.size ();i++) { if(!m_name[i].compare (field_name)) return i; } return -1; } /*-----------------------------------------------------*/ /* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ /* * 1 单条记录 * 2 [int ]操作 [""]操作 */ Record::Record(Field * m_f) { m_field =m_f; } Record::~Record(){}; void Record::SetData(string value) { m_rs.push_back (value); } /* [""]操作 */ string Record::operator[](string s) { return m_rs[m_field->GetField_NO(s)]; } string Record::operator[](int num) { return m_rs[num]; } /* null值判断 */ bool Record::IsNull(int num) { if("" == m_rs[num].c_str ()) return true; else return false; } bool Record::IsNull(string s) { if("" == m_rs[m_field->GetField_NO(s)].c_str()) return true; else return false; } /* 主要-功能:用 value tab value 的形式 返回结果 */ string Record::GetTabText() { string temp; for(unsigned int i=0 ;i<m_rs.size();i++) { temp+=m_rs[i]; if(i<m_rs.size ()-1) temp+="\t"; } return temp; } /*-----------------------------------------------------*/ /* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ /* * 1 记录集合 * 2 [int ]操作 [""]操作 * 3 表结构操作 * 4 数据的插入修改 */ RecordSet::RecordSet() { res = NULL; row = NULL; pos = 0; } RecordSet::RecordSet(MYSQL *hSQL) { res = NULL; row = NULL; m_Data = hSQL; pos = 0; } RecordSet::~RecordSet() { } /* * 处理返回多行的查询,返回影响的行数 * 成功返回行数,失败返回-1 */ int RecordSet::ExecuteSQL(const char *SQL) { if ( !mysql_real_query(m_Data,SQL,strlen(SQL))) { //保存查询结果 res = mysql_store_result(m_Data ); //得到记录数量 m_recordcount = (int)mysql_num_rows(res) ; //得到字段数量 m_field_num = mysql_num_fields(res) ; for (int x = 0 ; fd = mysql_fetch_field(res); x++) { m_field.m_name.push_back(fd->name); m_field.m_type.push_back(fd->type); } //保存所有数据 while (row = mysql_fetch_row(res)) { Record temp(&m_field); for (int k = 0 ; k < m_field_num ; k++ ) { if(row[k]==NULL||(!strlen(row[k]))) { temp.SetData (""); } else { temp.SetData(row[k]); } } //添加新记录 m_s.push_back (temp); } mysql_free_result(res ) ; return m_s.size(); } return -1; } /* * 向下移动游标 * 返回移动后的游标位置 */ long RecordSet::MoveNext() { return (++pos); } /* 移动游标 */ long RecordSet::Move(long length) { int l = pos + length; if(l<0) { pos = 0; return 0; }else { if(l >= m_s.size()) { pos = m_s.size()-1; return pos; }else { pos = l; return pos; } } } /* 移动游标到开始位置 */ bool RecordSet::MoveFirst() { pos = 0; return true; } /* 移动游标到结束位置 */ bool RecordSet::MoveLast() { pos = m_s.size()-1; return true; } /* 获取当前游标位置 */ unsigned long RecordSet::GetCurrentPos()const { return pos; } /* 获取当前游标的对应字段数据 */ bool RecordSet::GetCurrentFieldValue(const char * sFieldName, char *sValue) { strcpy(sValue,m_s[pos][sFieldName].c_str()); return true; } bool RecordSet::GetCurrentFieldValue(const int iFieldNum,char *sValue) { strcpy(sValue,m_s[pos][iFieldNum].c_str()); return true; } /* 获取游标的对应字段数据 */ bool RecordSet::GetFieldValue(long index,const char * sFieldName, char *sValue) { strcpy(sValue,m_s[index][sFieldName].c_str()); return true; } bool RecordSet::GetFieldValue(long index,int iFieldNum,char *sValue) { strcpy(sValue,m_s[index][iFieldNum].c_str()); return true; } /* 是否到达游标尾部 */ bool RecordSet::IsEof() { return (pos == m_s.size())?true:false; } /* * 得到记录数目 */ int RecordSet::GetRecordCount() { return m_recordcount; } /* * 得到字段数目 */ int RecordSet::GetFieldNum() { return m_field_num; } /* * 返回字段 */ Field * RecordSet::GetField() { return &m_field; } /* 返回字段名 */ const char * RecordSet::GetFieldName(int iNum) { return m_field.m_name.at(iNum).c_str(); } /* 返回字段类型 */ const int RecordSet::GetFieldType(char * sName) { int i = m_field.GetField_NO(sName); return m_field.m_type.at(i); } const int RecordSet::GetFieldType(int iNum) { return m_field.m_type.at(iNum); } /* * 返回指定序号的记录 */ Record RecordSet::operator[](int num) { return m_s[num]; } /* -------------------------------------------------- */ /* +++++++++++++++++++++++++++++++++++++++++++++++++++ */ /* * 1 负责数据库的连接关闭 * 2 执行sql 语句(不返回结果) * 3 处理事务 */ DataBase::DataBase() { m_Data = NULL; } DataBase::~DataBase() { if(NULL != m_Data) { DisConnect(); } } /* 返回句柄 */ MYSQL * DataBase::GetMysql() { return m_Data; } /* * 主要功能:连接数据库 * 参数说明: * 1 host 主机ip地址或者时主机名称 * 2 user 用户名 * 3 passwd 密码 * 4 db 欲连接的数据库名称 * 5 port 端口号 * 6 uinx 嵌套字 * 7 client_flag 客户连接参数 * 返回值: 0成功 -1 失败 */ int DataBase::Connect(string host, string user, string passwd, string db, unsigned int port, unsigned long client_flag) { if((m_Data = mysql_init(NULL)) && mysql_real_connect( m_Data, host.c_str(), user.c_str(), passwd.c_str(), db.c_str(),port , NULL, client_flag)) { //选择制定的数据库失败 if ( mysql_select_db( m_Data, db.c_str () ) < 0 ) { mysql_close( m_Data) ; return -1 ; } } else { //初始化mysql结构失败 mysql_close( m_Data ); return -1 ; } //成功 return 0; } /* * 关闭数据库连接 */ void DataBase::DisConnect( ) { mysql_close(m_Data) ; } /* * 主要功能: 执行非返回结果查询 * 参数:sql 待执行的查询语句 * 返回值; n为成功 表示受到影响的行数 -1 为执行失败 */ int DataBase::ExecQuery(string sql) { if(!mysql_real_query(m_Data,sql.c_str (),(unsigned long)sql.length()) ) { //得到受影响的行数 return (int)mysql_affected_rows(m_Data) ; } else { //执行查询失败 return -1; } } /* * 主要功能:测试mysql服务器是否存活 * 返回值:0 表示成功 -1 失败 */ int DataBase::Ping() { if(!mysql_ping(m_Data)) return 0; else return -1; } /* * 主要功能:关闭mysql 服务器 * 返回值;0成功 -1 失败 */ int DataBase::ShutDown() { if(!mysql_shutdown(m_Data,SHUTDOWN_DEFAULT)) return 0; else return -1; } /* * 主要功能:重新启动mysql 服务器 * 返回值;0表示成功 -1 表示失败 */ int DataBase::ReBoot() { if(!mysql_reload(m_Data)) return 0; else return -1; } /* * 说明:事务支持InnoDB or BDB表类型 */ /* * 主要功能:开始事务 */ int DataBase::Start_Transaction() { if(!mysql_real_query(m_Data, "START TRANSACTION" , (unsigned long)strlen("START TRANSACTION") )) { return 0; } else //执行查询失败 return -1; } /* * 主要功能:提交事务 * 返回值:0 表示成功 -1 表示失败 */ int DataBase::Commit() { if(!mysql_real_query( m_Data, "COMMIT", (unsigned long)strlen("COMMIT") ) ) { return 0; } else //执行查询失败 return -1; } /* * 主要功能:回滚事务 * 返回值:0 表示成功 -1 表示失败 */ int DataBase::Rollback() { if(!mysql_real_query(m_Data, "ROLLBACK", (unsigned long)strlen("ROLLBACK") ) ) return 0; else //执行查询失败 return -1; } /* 得到客户信息 */ const char * DataBase::Get_client_info() { return mysql_get_client_info(); } /*主要功能:得到客户版本信息*/ const unsigned long DataBase::Get_client_version() { return mysql_get_client_version(); } /* 主要功能:得到主机信息 */ const char * DataBase::Get_host_info() { return mysql_get_host_info(m_Data); } /* 主要功能:得到服务器信息 */ const char * DataBase::Get_server_info() { return mysql_get_server_info( m_Data ); } /* 主要功能:得到服务器版本信息 */ const unsigned long DataBase::Get_server_version() { return mysql_get_server_version(m_Data); } /*主要功能:得到 当前连接的默认字符集*/ const char * DataBase::Get_character_set_name() { return mysql_character_set_name(m_Data); } /* * 主要功能返回单值查询 */ char * DataBase::ExecQueryGetSingValue(string sql) { MYSQL_RES * res; MYSQL_ROW row ; char *p = NULL; if(!mysql_real_query( m_Data, sql.c_str(),(unsigned long)sql.length())) { //保存查询结果 res = mysql_store_result( m_Data ) ; row = mysql_fetch_row( res ) ; p = ((row[0]==NULL)||(!strlen(row[0])))?"-1":row[0]; mysql_free_result( res ) ; } else //执行查询失败 p = "-1"; return p; } /* * 得到系统时间 */ const char * DataBase::GetSysTime() { return ExecQueryGetSingValue("select now()"); } /* * 主要功能:建立新数据库 * 参数:name 为新数据库的名称 * 返回:0成功 -1 失败 */ int DataBase::Create_db(string name) { string temp ; temp="CREATE DATABASE "; temp+=name; if(!mysql_real_query( m_Data,temp.c_str () , (unsigned long)temp.length ()) ) return 0; else //执行查询失败 return -1; } /* * 主要功能:删除制定的数据库 * 参数:name 为欲删除数据库的名称 * 返回:0成功 -1 失败 */ int DataBase::Drop_db(string name) { string temp ; temp="DROP DATABASE "; temp+=name; if(!mysql_real_query( m_Data,temp.c_str () , (unsigned long)temp.length ()) ) return 0; else //执行查询失败 return -1; } /*-----------------------------------------------------*/ }; /* * 使用例子 */ #include "zlb_mysql.h" using namespace std; void main() { zlb_mysql::DataBase zlb; //连接数据库 if(-1 == zlb.Connect("localhost"/*本地数据库,可以是远程 ip*/, "root"/*用户名*/,"apple"/*密码*/, "test"/*数据库名*/, 0,0/*两个标志,mysql文档有说明,一般为0*/)) { std::cout<<"connect failed "<<std::endl; } else { std::cout<<"connect success"<<std::endl; } //通过返回的数据库句柄,建立记录急,你可以通过返回的这个句柄建立多个记录急 zlb_mysql::RecordSet rs(zlb.GetMysql()); rs.ExecuteSQL("select * from testtable");//这个语句大家都知道是什么意思了 cout<<rs.GetRecordCount()/*返回的总的记录数*/<<endl; cout<<rs.GetFieldNum()/*返回的总的字段数*/<<endl; cout<<rs[0].GetTabText()/*返回第一条记录,你也可以rs[1].GetTabText() 如果你有多条记录, */ <<endl; /*实现遍列,也可以使用后面的遍列方式*/ for(int i=0;i<rs.GetRecordCount();++i) { for(int j =0;j<rs.GetFieldNum();++j) cout<<rs[i][j]; cout<<endl; } zlb_mysql::Field *fd = rs.GetField();/*你可以通过这样的方式,获取字段的信息*/ cout<<fd->GetField_NO("Password")/*返回我表里的 Password 字段的位置,不 是记录的位置*/ <<endl; cout<<rs[0]["Password"]<<endl;/*输出第0行第Password列的值*/ cout<<rs[0][fd->GetField_NO("Password")]<<endl;/*你也可以这样*/ cout<<rs.GetFieldName(0)/*获取字段的名字*/<<endl; cout<<rs.GetFieldType("UserName")/*获取字段的类型,是mysql里定义的*/<<endl; cout<<rs.GetCurrentPos()/*获取当前记录的位置*/<<endl; char s[50]; rs.GetCurrentFieldValue(1,s);/*获取当前记录对应字段的值*/ cout<<s<<endl; cout<<rs.Move(1)<<endl;/*移动游标,正数往前 负数往后*/ cout<<rs.GetCurrentPos()<<endl; rs.GetCurrentFieldValue(1,s); cout<<s<<endl; rs.MoveFirst();/*移动游标到最前*/ while(!rs.IsEof()/*判断是否到达游标尾,实现遍列*/) { rs.GetCurrentFieldValue("UserName",s); cout<<s<<"\t"; rs.GetCurrentFieldValue("Password",s); cout<<s<<"\t
"; rs.MoveNext(); } rs.GetFieldValue(0,"UserName",s);/*获取指定行 的记录值*/ cout<<s<<"\t"; rs.GetFieldValue(0,"Password",s); cout<<s<<"\t
"; }

❺ c/c++写服务器一般用什么方式访问数据库的

要做服务器端的话数据库就是放在你的服务器上的, 数据库会提供相应的访问接口, 具体使用方式可以搜一下"C++连接数据库"之类的
http是客户端访问服务器才用得到, 直接操作数据库的总是服务器端而不是客户端

❻ 用c语言怎么连接数据库呢

25.2.2. C API函数概述
这里归纳了C API可使用的函数,并在下一节详细介绍了它们。请参见25.2.3节,“C API函数描述”。

函数
描述

mysql_affected_rows()
返回上次UPDATE、DELETE或INSERT查询更改/删除/插入的行数。

mysql_autocommit()
切换 autocommit模式,ON/OFF

mysql_change_user()
更改打开连接上的用户和数据库。

mysql_charset_name()
返回用于连接的默认字符集的名称。

mysql_close()
关闭服务器连接。

mysql_commit()
提交事务。

mysql_connect()
连接到MySQL服务器。该函数已不再被重视,使用mysql_real_connect()取代。

mysql_create_db()
创建数据库。该函数已不再被重视,使用SQL语句CREATE DATABASE取而代之。

mysql_data_seek()
在查询结果集中查找属性行编号。

mysql_debug()
用给定的字符串执行DBUG_PUSH。

mysql_drop_db()
撤销数据库。该函数已不再被重视,使用SQL语句DROP DATABASE取而代之。

mysql_mp_debug_info()
让服务器将调试信息写入日志。

mysql_eof()
确定是否读取了结果集的最后一行。该函数已不再被重视,可以使用mysql_errno()或mysql_error()取而代之。

mysql_errno()
返回上次调用的MySQL函数的错误编号。

mysql_error()
返回上次调用的MySQL函数的错误消息。

mysql_escape_string()
为了用在SQL语句中,对特殊字符进行转义处理。

mysql_fetch_field()
返回下一个表字段的类型。

mysql_fetch_field_direct()
给定字段编号,返回表字段的类型。

mysql_fetch_fields()
返回所有字段结构的数组。

mysql_fetch_lengths()
返回当前行中所有列的长度。

mysql_fetch_row()
从结果集中获取下一行

mysql_field_seek()
将列光标置于指定的列。

mysql_field_count()
返回上次执行语句的结果列的数目。

mysql_field_tell()
返回上次mysql_fetch_field()所使用字段光标的位置。

mysql_free_result()
释放结果集使用的内存。

mysql_get_client_info()
以字符串形式返回客户端版本信息。

mysql_get_client_version()
以整数形式返回客户端版本信息。

mysql_get_host_info()
返回描述连接的字符串。

mysql_get_server_version()
以整数形式返回服务器的版本号。

mysql_get_proto_info()
返回连接所使用的协议版本。

mysql_get_server_info()
返回服务器的版本号。

mysql_info()
返回关于最近所执行查询的信息。

mysql_init()
获取或初始化MYSQL结构。

mysql_insert_id()
返回上一个查询为AUTO_INCREMENT列生成的ID。

mysql_kill()
杀死给定的线程。

mysql_library_end()
最终确定MySQL C API库。

mysql_library_init()
初始化MySQL C API库。

mysql_list_dbs()
返回与简单正则表达式匹配的数据库名称。

mysql_list_fields()
返回与简单正则表达式匹配的字段名称。

mysql_list_processes()
返回当前服务器线程的列表。

mysql_list_tables()
返回与简单正则表达式匹配的表名。

mysql_more_results()
检查是否还存在其他结果。

mysql_next_result()
在多语句执行过程中返回/初始化下一个结果。

mysql_num_fields()
返回结果集中的列数。

mysql_num_rows()
返回结果集中的行数。

mysql_options()
为mysql_connect()设置连接选项。

mysql_ping()
检查与服务器的连接是否工作,如有必要重新连接。

mysql_query()
执行指定为“以Null终结的字符串”的SQL查询。

mysql_real_connect()
连接到MySQL服务器。

mysql_real_escape_string()
考虑到连接的当前字符集,为了在SQL语句中使用,对字符串中的特殊字符进行转义处理。

mysql_real_query()
执行指定为计数字符串的SQL查询。

mysql_refresh()
刷新或复位表和高速缓冲。

mysql_reload()
通知服务器再次加载授权表。

mysql_rollback()
回滚事务。

mysql_row_seek()
使用从mysql_row_tell()返回的值,查找结果集中的行偏移。

mysql_row_tell()
返回行光标位置。

mysql_select_db()
选择数据库。

mysql_server_end()
最终确定嵌入式服务器库。

mysql_server_init()
初始化嵌入式服务器库。

mysql_set_server_option()
为连接设置选项(如多语句)。

mysql_sqlstate()
返回关于上一个错误的SQLSTATE错误代码。

mysql_shutdown()
关闭数据库服务器。

mysql_stat()
以字符串形式返回服务器状态。

mysql_store_result()
检索完整的结果集至客户端。

mysql_thread_id()
返回当前线程ID。

mysql_thread_safe()
如果客户端已编译为线程安全的,返回1。

mysql_use_result()
初始化逐行的结果集检索。

mysql_warning_count()
返回上一个SQL语句的告警数。 详见:http://dev.mysql.com/doc/refman/5.1/zh/apis.html#c-api-function-overview
http://dev.mysql.com/doc/refman/5.0/en/c.html

❼ 请问c语言如何访问数据库

那要看你访问什么数据库了,一般的数据库都会提供接口给你,具体的数据库要去查他们的文档

❽ c语言操作数据库有哪些

都是可以的C/C++与数据库交互,像mssql/mysql/oracle
等。一般都有成熟的第三方库。这些库里面无非就是封装了与数据库通讯的方式和通讯协议。

❾ 如何在c语言中编程访问数据库

第一种,数据库厂商提供的C变种,比如oracle的proc-c,简单点说,就是在C嵌入sql代码来实现数据库的访问。
第二种,数据库厂商提供的api,比如oracle的OCI。

热点内容
安卓70能用什么软件 发布:2025-05-16 01:45:09 浏览:480
编程发展史 发布:2025-05-16 01:38:52 浏览:528
android图片气泡 发布:2025-05-16 01:38:40 浏览:885
文件加密编辑器下载 发布:2025-05-16 01:30:41 浏览:343
linuxapacheyum安装 发布:2025-05-16 01:30:31 浏览:476
大连宾利浴池wifi密码是多少 发布:2025-05-16 01:25:36 浏览:172
缓存数据生产服务 发布:2025-05-16 01:08:58 浏览:584
普通电脑服务器图片 发布:2025-05-16 01:04:02 浏览:971
服务器地址和端口如何区分 发布:2025-05-16 01:03:17 浏览:834
重新编目数据库 发布:2025-05-16 00:54:34 浏览:514