
没有理由只能用手动建表。
我找了一段代码,还没试。谁能给个可用的代码
Here is an extract.....
I hope it helps.
please remember....u need to compile it with
-lmysqlclient -lz options.
#include <string.h>
#include <stdio.h>
#include "/usr/include/mysql/mysql.h"
MYSQL imysql
MYSQL_RES * mydata
unsigned int num_fields
unsigned int num_rows
unsigned long *lengths
MYSQL_ROW row,
MYSQL_FIELD *fields
char a[241]=""
char querystring[241]=""
void mysqlinit(char user[20], char password[20], char db[20])
void main()
{
mysqlinit("username","userpassword","database")
a[0] ='\0'
strcat(a,"Create Table ")
strcat(a,tablename)
strcat(a,"(pepsi bigint Not Null Primary,coke bigint Not Null)")
printf(a)
strcpy(querystring,a)
if (!mysql_real_query(&imysql,querystring,strlen(querystring)))
{mydata = mysql_store_result(&imysql) }
else
{ printf("Oops ! Error %d:
%s\n",mysql_errno(&imysql),mysql_error(&imysql))
mysql_close(&imysql)
exit(0)
}
mysql_close(&imysql)
}
void mysqlinit(char user[20], char password[20], char db[20])
{
mysql_init(&imysql)
mysql_options(&imysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name")
if (!mysql_real_connect(&imysql,"",user,password,db,0,NULL,0))
{
fprintf(stderr,"FAILED !!!! Error %s\n",mysql_error(&imysql))
}
else
{
printf( "Connection with Database established !\n")
}
}
没有办法一次性把数据绑定上去。除非你用控件。 比较快速的方法是,循环后台的table的每一行row的每一个column,然后把值对应的填充到前台的table中(前台table中,需要对应包含服务器控件。)获取表格的属性,然后就可以设置,参考方法如下:
Table newTable = WordDoc.Tables.Add(WordApp.Selection.Range, 10, 3, ref Nothing, ref Nothing)
//表格属性
newTable.Borders.OutsideLineStyle = WdLineStyle.wdLineStyleThickThinLargeGap
newTable.Borders.InsideLineStyle = WdLineStyle.wdLineStyleSingle
//列宽度
newTable.Columns[1].Width = 100f
newTable.Columns[2].Width = 200f
newTable.Columns[3].Width = 300f
//总宽度
float TableWidth=3个列宽相加
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)