MYSQL mysql/含昌/数据库连接句柄
MYSQL_RES *result
mysql_init (&mysql)
MYSQL_ROW sql_row
if(!mysql_real_connect(&mysql,"localhost"枝老肢,"root","密码","数据库名字",3306,NULL,0))
{//mydb为你所创建的数据库,3306为端口号,可自行设定
printf("数据库连接失败\n")
}
else
{ mysql_query(&mysql, "SET NAMES GBK")//设置字体,因为中文可能乱码
mysql_query(&mysql,"select * from 表名 where 公司名的字段名=‘你要搜的公司名’")//运行SQL语句
result=mysql_store_result(&mysql)
sql_row=mysql_fetch_row(result)//搜到的结果显示到数组sql_row[]
if(sql_row)
{
printf("没有找到")
return
}
输出sql_row[x]
//sql_row[x]就是结果,。x是字段在表的位置,第一个位置就是sql_row[0]。但是我不知道C语言如何输出
}
Private Sub CommandButton1_Click()With ActiveSheet.QueryTables.Add(Connection:= _
"TEXTC:\闹腊Documents and Settings\Administrator\桌面茄扮\颤弯灶123.txt", Destination:=Range _
("D2"))
.Name = "123"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 936
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)