當前位置:首頁 » 操作系統 » c獲取資料庫數據

c獲取資料庫數據

發布時間: 2022-05-03 20:28:21

❶ C#中如何連接sql資料庫 並獲取數據

Console.WriteLine("成功連接到資料庫!"); Console.WriteLine("data sourc:{0}",conn.DataSource); Console.WriteLine("database name:{0}",conn.Database); Console.WriteLine("client name:{0}",conn.WorkstationId); SqlCommand cmd=new SqlCommand("select CategoryID,CategoryName from Categories",conn); SqlDataReader dr=cmd.ExecuteReader(); while(dr.Read()){Console.WriteLine("\t{0}\t{1}",dr.GetInt32(0),dr.GetString(1));}dr.Close(); conn.Close();}catch(Exception e){Console.WriteLine("無法連接到資料庫!"); DataReader的意思就是數據閱讀器,它是以類似於指針的形式讀取資料庫裡面的記錄,具有效率高的特點。使用Read()方法可以將滿足查詢的記錄依次讀取出來,類似於指針的Next()方法。使用while循環可以讀取到全部記錄,讀取到最後一條記錄時退出循環。返回的值為Object類型,可以進行轉換以得到需要的數據。 示例:while(reader.Read()){string name = reader["name"].ToString(); // name為查詢語句中的name列}注意使用datareader必須及時關閉,否則會與資料庫建立長連接,消耗資料庫的連接數。關閉連接使用Close()方法或使用Using方法讓系統幫你自動釋放。 具體可參考MSDN SqlDataReader.Read()方法。

c語言關於從資料庫讀取數據寫文件

#include<stdio.h>
execsqlincludesqlca;

intmain(){
execsqlbegindeclaresection;
charuserpasswd[30]="openlab/123456";
struct{
intid;
charname[30];
doublesalary;
}emp;
execsqlenddeclaresection;
execsqlconnect:userpasswd;

selectid,first_name,salaryfrom
s_emporderbysalary;
execsqlopenempcursor;
;
for(;;){
execsqlfetchempcursorinto:emp;
printf("%d:%s:%lf ",emp.id,emp.name,
emp.salary);
}
execsqlcloseempcursor;
execsqlcommitworkrelease;
}

把數據存到結構體里。

❸ 在c語言中,如何提取一個txt資料庫文件中的信息

簡單的用C讀取文件的例子代碼片段。
... ...
FILE *fp;
char buffer[1000];
fp=fopen( "input.txt", "r" );
while ( fread(&buffer, sizeof(buffer), 1, fp )==1)
{
... ...
//對從文件讀出來的數據在此處進行處理
... ...
}
fclose(fp);
... ...

❹ 如何用C語言取數據

//其中的in.txt就是你要讀取數據的文件,當然把它和程序放在同一目錄
-------------------------------------
#include
<stdio.h>
int
main()
{
int
data;
FILE
*fp=fopen("in.txt","r");
if(!fp)
{
printf("can't
open
file\n");
return
-1;
}
while(!feof(fp))
{
fscanf(fp,"%d",&data);
printf("%4d",data);
}
printf("\n");
fclose(fp);
return
0;
}
2
猴島ID
飯叔為你解答
望採納

❺ uo_tool_c獲取資料庫參數出錯沒有配置應用伺服器地址

摘要 親,您的這個問題我已經幫您找到答案親,問題的原因:此問題屬於sql server的bug, GetComputerName 用於獲取本地計算機名。客戶端網路庫組件 (DBMSLPCn.dll) 將該名稱轉換為全部大寫。伺服器網路庫組件 (SSMSLPCn.dll) 保留返回時的名稱。當 Windows 計算機名稱包含大寫字母和小寫字母或者都是小寫字母時安裝會失敗,提示一般性網路錯誤!解決辦法就是將計算機名稱改為全部大寫

❻ 如何用c語言提取excel中的數據

1.方法一:採用OleDB讀取EXCEL文件:

把EXCEL文件當做一個數據源來進行數據的讀取操作,實例如下:

publicDataSetExcelToDS(stringPath)

{

stringstrConn="Provider=Microsoft.Jet.OLEDB.4.0;"+"DataSource="+Path+";"+"ExtendedProperties=Excel8.0;";

OleDbConnectionconn=newOleDbConnection(strConn);

conn.Open();

stringstrExcel="";

OleDbDataAdaptermyCommand=null;

DataSetds=null;

strExcel="select*from[sheet1$]";

myCommand=newOleDbDataAdapter(strExcel,strConn);

ds=newDataSet();

myCommand.Fill(ds,"table1");

returnds;

}

對於EXCEL中的表即sheet([sheet1$])如果不是固定的可以使用下面的方法得到

stringstrConn="Provider=Microsoft.Jet.OLEDB.4.0;"+"DataSource="+Path+";"+"ExtendedProperties=Excel8.0;";

OleDbConnectionconn=newOleDbConnection(strConn);

DataTableschemaTable=objConn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,null);

stringtableName=schemaTable.Rows[0][2].ToString().Trim();

另外:也可進行寫入EXCEL文件,實例如下:
publicvoidDSToExcel(stringPath,DataSetoldds)

{

//先得到匯總EXCEL的DataSet主要目的是獲得EXCEL在DataSet中的結構

stringstrCon="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="+path1+";ExtendedProperties=Excel8.0";

OleDbConnectionmyConn=newOleDbConnection(strCon);

stringstrCom="select*from[Sheet1$]";

myConn.Open();

OleDbDataAdaptermyCommand=newOleDbDataAdapter(strCom,myConn);

ystem.Data.OleDb.OleDbCommandBuilderbuilder=newOleDbCommandBuilder(myCommand);

//QuotePrefix和QuoteSuffix主要是對builder生成InsertComment命令時使用。

builder.QuotePrefix="[";//獲取insert語句中保留字元(起始位置)

builder.QuoteSuffix="]";//獲取insert語句中保留字元(結束位置)

DataSetnewds=newDataSet();

myCommand.Fill(newds,"Table1");

for(inti=0;i<oldds.Tables[0].Rows.Count;i++)

{

在使用ImportRow後newds內有值,但不能更新到Excel中因為所有導入行的

DataRowState!=Added

DataRownrow=aDataSet.Tables["Table1"].NewRow();

for(intj=0;j<newds.Tables[0].Columns.Count;j++)

{

nrow[j]=oldds.Tables[0].Rows[i][j];

}

newds.Tables["Table1"].Rows.Add(nrow);

}

myCommand.Update(newds,"Table1");

myConn.Close();

}

2.方法二:引用的com組件:Microsoft.Office.Interop.Excel.dll讀取EXCEL文件
首先是Excel.dll的獲取,將Office安裝目錄下的Excel.exe文件Copy到DotNet的bin目錄下,cmd到該目錄下,運行TlbImpEXCEL.EXEExcel.dll得到Dll文件。再在項目中添加引用該dll文件.
//讀取EXCEL的方法(用范圍區域讀取數據)

privatevoidOpenExcel(stringstrFileName)

{

objectmissing=System.Reflection.Missing.Value;

Applicationexcel=newApplication();//lauchexcelapplication

if(excel==null)

{

Response.Write("<script>alert('Can'taccessexcel')</script>");

}

else

{

excel.Visible=false;excel.UserControl=true;

//以只讀的形式打開EXCEL文件

Workbookwb=excel.Application.Workbooks.Open(strFileName,missing,true,missing,missing,missing,

missing,missing,missing,true,missing,missing,missing,missing,missing);

//取得第一個工作薄

Worksheetws=(Worksheet)wb.Worksheets.get_Item(1);

//取得總記錄行數(包括標題列)

introwsint=ws.UsedRange.Cells.Rows.Count;//得到行數

//intcolumnsint=mySheet.UsedRange.Cells.Columns.Count;//得到列數

//取得數據范圍區域(不包括標題列)

Rangerng1=ws.Cells.get_Range("B2","B"+rowsint);//item

Rangerng2=ws.Cells.get_Range("K2","K"+rowsint);//Customer

object[,]arryItem=(object[,])rng1.Value2;//getrange'svalue

object[,]arryCus=(object[,])rng2.Value2;

//將新值賦給一個數組

string[,]arry=newstring[rowsint-1,2];

for(inti=1;i<=rowsint-1;i++)

{

//Item_Code列

arry[i-1,0]=arryItem[i,1].ToString();

//Customer_Name列

arry[i-1,1]=arryCus[i,1].ToString();

}

Response.Write(arry[0,0]+"/"+arry[0,1]+"#"+arry[rowsint-2,0]+"/"+arry[rowsint-2,1]);

}

excel.Quit();excel=null;

Process[]procs=Process.GetProcessesByName("excel");

foreach(Processproinprocs)

{

pro.Kill();//沒有更好的方法,只有殺掉進程

}

GC.Collect();

}

3.方法三:將EXCEL文件轉化成CSV(逗號分隔)的文件,用文件流讀取(等價就是讀取一個txt文本文件)。


先引用命名空間:usingSystem.Text;和usingSystem.IO;

FileStreamfs=newFileStream("d:\Customer.csv",FileMode.Open,FileAccess.Read,FileShare.None);

StreamReadersr=newStreamReader(fs,System.Text.Encoding.GetEncoding(936));

stringstr="";

strings=Console.ReadLine();

while(str!=null)

{str=sr.ReadLine();

string[]xu=newString[2];

xu=str.Split(',');

stringser=xu[0];

stringdse=xu[1];if(ser==s)

{Console.WriteLine(dse);break;

}

}sr.Close();

另外也可以將資料庫數據導入到一個txt文件,實例如下:
//txt文件名

stringfn=DateTime.Now.ToString("yyyyMMddHHmmss")+"-"+"PO014"+".txt";

OleDbConnectioncon=newOleDbConnection(conStr);

con.Open();

stringsql="selectITEM,REQD_DATE,QTY,PUR_FLG,PO_NUMfromTSD_PO014";

//OleDbCommandmycom=newOleDbCommand("select*fromTSD_PO014",mycon);

//OleDbDataReadermyreader=mycom.ExecuteReader();//也可以用Reader讀取數據

DataSetds=newDataSet();

OleDbDataAdapteroda=newOleDbDataAdapter(sql,con);

oda.Fill(ds,"PO014");

DataTabledt=ds.Tables[0];

FileStreamfs=newFileStream(Server.MapPath("download/"+fn),FileMode.Create,FileAccess.ReadWrite);

StreamWriterstrmWriter=newStreamWriter(fs);//存入到文本文件中

//把標題寫入.txt文件中

//for(inti=0;i<dt.Columns.Count;i++)

//{

//strmWriter.Write(dt.Columns[i].ColumnName+"");

//}

foreach(DataRowdrindt.Rows)

{

stringstr0,str1,str2,str3;

stringstr="|";//數據用"|"分隔開

str0=dr[0].ToString();

str1=dr[1].ToString();

str2=dr[2].ToString();

str3=dr[3].ToString();

str4=dr[4].ToString().Trim();

strmWriter.Write(str0);

strmWriter.Write(str);

strmWriter.Write(str1);

strmWriter.Write(str);

strmWriter.Write(str2);

strmWriter.Write(str);

strmWriter.Write(str3);

strmWriter.WriteLine();//換行

}

strmWriter.Flush();

strmWriter.Close();

if(con.State==ConnectionState.Open)

{

con.Close();

}

❼ 關於c語言如何讀取數據

你要讀哪3位?
連著一起的3位,還是獨立的3位

連一起: (val&(0x07<<n))>>n
0-2: (val&0x07)>>0
1-3: (val&0x0e)>>1
2-4: (val&0x1c)>>2
3-5: (val&0x38)>>3
4-6: (val&0x70)>>4
5-7L (val&0xe0)>>5

單獨第n位:
(val&(0x1<<n))>>n

❽ C #里的request如何獲取資料庫中表中的記錄

首先需要說明,在C#中REQUST有兩種.
1. 位於System.Web.HttpRequest是封裝瀏覽器對伺服器的請求的,主要用在ASP.NET中,其中包括瀏覽器請求的網址,查詢字元串數據或表單數據等等.
所以一般將System.Web.HttpReques中的Request通常都簡稱為request,即:"請求",有"請求"就有"響應(response)".

在實際開發中,最常見的使用方法就是在ASP.NET中利用request對像用於獲取FORM中各種控種的值,或者用於接收URL傳參時的值.無法用來獲取資料庫或虛擬表中的記錄.
注:FORM中各種控制項的值可以是用戶輸入,或者從資料庫中取出來的數據綁定.
例如:
Request.Params["string型參數名"],Request.QueryString["string型參數名"]用於獲取URL傳參時某個參數的值.
Request.Form["控制項名稱"]用於獲取服務端控制項FORM中的各種控制項的值.

2.位於System.Net.HttpWebRequest則是用來簡化網路請求的過程,從伺服器上獲取文件/結果的,譬如你可以在代碼中用這個類冒充瀏覽器(設置一個UserAgent)來發請求,處理回應
這里的Rquest通常用於請求獲取服務端的各種文件數據流,例如在程序中點里某個按扭將伺服器上的某個地址的文件下載到本地硬碟.這個request在使用時由先創建一個對像實例.
例如:
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("下載地址,比如說某個網址") 首先創建REQUEST對像,
request.GetResponse().GetResponseStream()創建完成後就可以通過它來獲取流中的數據了,然後將獲取的數據交給System.IO.Stream的實例對像,就可以對需要下載的數據流進行處理了.
同樣,它也有一個與之相匹配的RESPONSE響應對像.這里就不再說明了...

這種問概念性的問題記著多看看書就能找到明確的答案.
以後不要再問這么沒水平的問題了.會鬧出笑話的...

至於System.Web.HttpRequest與System.Net.HttpWebRequest具體的區別,以後從書上給抄了一段內容:

HttpWebRequest 類對 WebRequest 中定義的屬性和方法提供支持,也對使用戶能夠直接與使用 HTTP 的伺服器交互的附加屬性和方法提供支持。
不要使用 HttpWebRequest 構造函數。使用 WebRequest.Create 方法初始化新的 HttpWebRequest 對象。如果統一資源標識符 (URI) 的方案是 http:// 或 https://,則 WebRequest.Create 返回 HttpWebRequest 對象。
可以使用 BeginGetResponse 和 EndGetResponse 方法對資源發出非同步請求。BeginGetRequestStream 和 EndGetRequestStream 方法提供對發送數據流的非同步訪問
如果在訪問資源時發生錯誤,則 HttpWebRequest 類將引發 WebException。WebException.Status 屬性包含指示錯誤源的 WebExceptionStatus 值。
HttpWebRequest 將發送到 Internet 資源的公共 HTTP 標頭值公開為屬性,由方法或系統設置;下表包含完整列表。可以將 Headers 屬性中的其他標頭設置為名稱/值對。注意,伺服器和緩存在請求期間可能會更改或添加標頭。
下表列出了由屬性或方法設置或由系統設置的 HTTP 標頭。
System.Web.HttpRequest是封裝瀏覽器對伺服器的請求的,主要用在ASP.NET中,其中包括瀏覽器請求的網址,查詢字元串數據或表單數據等等
而System.Net.HttpWebRequest則是用來簡化網路請求的過程,從伺服器上獲取文件/結果的,譬如你可以在代碼中用這個類冒充瀏覽器(設置一個UserAgent)來發請求,處理回應
第一:他們不是父子關系。
第二:Syste.Net.HttpWebRequest類是System.Net.WebRequest抽象類的一個子類,它是.NET Framework的用於訪問Internet數據的請求/響應模型的抽象基類。使用該請求/響應模型的應用程序可以用協議不可知的方式從Internet請求數據。在這種方式下,應用程序處理 WebRequest類的實例,而協議特定的子類則執行請求的具體細節。
System.Net.HttpWebRequest類和System.Net.FileWebRequest都繼承了WebRequest
1、FileWebRequest類為使用file:// 方案來請求本地文件的URI實現WebRequest抽象基類。
2、HttpWebRequest類對WebRequest中定義的屬性和方法提供支持,也對使用戶能夠直接與使用HTTP的伺服器交互的附加屬性和方法提供支持。
第三:System.Web.HttpRequest類使ASP.NET能夠讀取客戶端在Web 請求期間發送的 HTTP值,HttpRequest類的方法和屬性通過HttpApplication、HttpContext、Page 和 UserControl類的Request屬性公開。
所以使用System.Web.HttpRequest類的時候其實都是利用HttpApplication、HttpContext、Page和UserControl類的Request屬性。而使用System.Net.HttpWebRequest類時是為了獲得一個Uri資源。自己創建。
System.Web 命名空間提供使得可以進行瀏覽器與伺服器通信的類和介面。此命名空間包括 HttpRequest 類(用於提供有關當前 HTTP 請求的廣泛信息)、HttpResponse 類(用於管理對客戶端的 HTTP 輸出)以及 HttpServerUtility 類(用於提供對伺服器端實用工具與進程的訪問)。System.Web 還包括用於 Cookie 操作、文件傳輸、異常信息和輸出緩存控制的類。
System.Net 命名空間為當前網路上使用的多種協議提供了簡單的編程介面。WebRequest 和 WebResponse 類形成了所謂的可插接式協議的基礎,可插接式協議是網路服務的一種實現,它使您能夠開發出使用 Internet 資源的應用程序,而不必考慮各種不同協議的具體細節。

❾ 求教如何在 c/c++中讀取資料庫中表的數據!!!!!!!!!

int CountLines(char *filename) { ifstream ReadFile; int n=0; char line[512]; ReadFile.open(filename,ios::in);//ios::in 表示以只讀的方式讀取文件 if(ReadFile.fail())//文件打開失敗:返回0 { return 0; } else//文件存在 { while(!ReadFile.eof()) { ReadFile.getline(line,512,'\n'); n++; } return n; }

❿ C++ 獲得資料庫中的數據

1.提取單條記錄
/*
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
*/
CoInitialize(NULL);
_bstr_t varSource="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=*.mdb";
//_bstr_t varSource="Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"
_ConnectionPtr m_pConnection(_uuidof(Connection));
m_pConnection->Open(varSource,"","",adModeUnknow);
_RecordsetPtr m_pSet(_uuid(Recordset));
try {
m_pSet->Open(%%1,m_pConnection.GetInterfacePtr()
adOpenDynamic,adLockPessimistic,adCmdText);
}
catch(_com_error *e){
{
AfxMessageBox(e->ErrorMessage());
return;
}
_variant_t var;
CString %%2="";
long fldc=m_pSet->GetFields()->GetCount();
long i=0;
try {
m_pSet->MoveFirst();
if(!m_pSet->adoEOF)
{
for(i=0;i<fldc;i++)
{
var=m_pSet->GetCollect((long)i);
var.ChangeType(VT_BSTR);
%%2+=var.bstrVal;
%%2+=" ";
}
//m_pSet->MoveNext();
}
}
catch(_com_error *e){
AfxMessageBox(e->ErrorMessage());
delete e;
}
//m_pSet->MoveFirst();
CoUninitialize(NULL);

3.顯示表格
/*
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
*/
CoInitialize(NULL);
_bstr_t varSource="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=*.mdb";
//_bstr_t varSource="Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"
_ConnectionPtr m_pConnection(_uuidof(Connection));
m_pConnection->Open(varSource,"","",adModeUnknow);
//打開屬性為默認(adModeRead(只讀),adModeWrite(可寫),adModeReadWrite(可讀寫)等)
_RecordsetPtr m_pSet(_uuid(Recordset));
try {
HRESULT hr=m_pSet->Open(%%1,m_pConnection.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
}
catch(_com_error *e){
AfxMessageBox(e->ErrorMessage());
}
if(SUCCESSED(hr))
{
//表打開成功
}
FieldsPtr p_fields=m_pSet->Fields;
FieldPtr p_field;
_variant_t var_index;
LPCSTR field_name;
int index=0;
_bstr_t bstr_field_name;
int countfields=p_fields->GetCount();
CString *Column=new CString[countfields];
CListCtrl *pList=(CListCtrl*)GetDlgItem(%%1);//IDC_LIST_TABLEDATA
VERIFY(pList);
pList->DeleteAllItems();
for(index=0;index<countfields;index++)
{
var_index.vt=VT_I4;
var_index.IVal=index;
p_field=p_fields->Item[var_index];
bstr_field_name=p_field->GetName();
field_name=(LPCSTR)bstr_field_name;
Column[index]=field_name;
int ColumnWidth=Column[index].GetLength()*15;
pList->InsertColumn(index,field_name,LVCFMT_CENTER,ColumnWidth);
}
int i=0;
_bstr_t vCol;
//pList->SetTextBkColor(RGB(122,200,122));
//pList->SetTextColor(RGB(0,0,200));
while(!m_pSet->adoEOF)
{
pList->Insert(i,atoi(i));
for(int j=0;j<countfields;j++)
{
vCol=m_pSet->GetCollect((long)j);
pList->SetItemText(i,j,vCol);
}
m_pSet->MoveNext();
i++;
}
CoUninitialize(NULL);

4.操作表格
/*
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
*/
CoInitialize(NULL);
_bstr_t varSource="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=*.mdb";
//_bstr_t varSource="Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"
_ConnectionPtr m_pConnection(_uuidof(Connection));
m_pConnection->Open(varSource,"","",adModeUnknow);
//打開屬性為默認(adModeRead(只讀),adModeWrite(可寫),adModeReadWrite(可讀寫)等)
_RecordsetPtr m_pSet(_uuid(Recordset));
try {
HRESULT hr=m_pSet->Open(%%1,m_pConnection.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
}
catch(_com_error *e){
AfxMessageBox(e->ErrorMessage());
}
if(SUCCESSED(hr))
{
//表打開成功
}
FieldsPtr p_fields=m_pSet->Fields;
FieldPtr p_field;
_variant_t var_index;
LPCSTR field_name;
int index=0;
_bstr_t bstr_field_name;
int countfields=p_fields->GetCount();
CString *Column=new CString[countfields];
CListCtrl *pList=(CListCtrl*)GetDlgItem(%%1);//IDC_LIST_TABLEDATA
VERIFY(pList);
pList->DeleteAllItems();
for(index=0;index<countfields;index++)
{
var_index.vt=VT_I4;
var_index.IVal=index;
p_field=p_fields->Item[var_index];
bstr_field_name=p_field->GetName();
field_name=(LPCSTR)bstr_field_name;
Column[index]=field_name;
int ColumnWidth=Column[index].GetLength()*15;
pList->InsertColumn(index,field_name,LVCFMT_CENTER,ColumnWidth);
}
int i=0;
_bstr_t vCol;
//pList->SetTextBkColor(RGB(122,200,122));
//pList->SetTextColor(RGB(0,0,200));
while(!m_pSet->adoEOF)
{
pList->Insert(i,atoi(i));
for(int j=0;j<countfields;j++)
{
vCol=m_pSet->GetCollect((long)j);
pList->SetItemText(i,j,vCol);
}
m_pSet->MoveNext();
i++;
}
CoUninitialize(NULL);

5.數值范圍查詢
/*
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "EndOfFile")
*/
try
{
//創建連接對象實例
m_pConnection.CreateInstance("ADODB.Connection");
//設置連接字元串
CString strConnect="DRIVER={Microsoft Access Driver (*.mdb)};\
uid=;pwd=;DBQ=shujuku.mdb;";
//使用Open方法連接資料庫
m_pConnection->Open((_bstr_t)strConnect,"","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox(e.Description());
}
}
try {
int min = %%1;
int max = %%2;
CString sql;
sql.Format("select count(*) as pro_count from ProPrice where price between %d and %d",min,max);
HRESULT hr=m_pSet->Open(sql,m_pConnection.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
}
catch(_com_error *e){
AfxMessageBox(e->ErrorMessage());
}
if(SUCCESSED(hr))
{
//表打開成功
}
FieldsPtr p_fields=m_pSet->Fields;
FieldPtr p_field;
_variant_t var_index;
LPCSTR field_name;
int index=0;
_bstr_t bstr_field_name;
int countfields=p_fields->GetCount();
CString *Column=new CString[countfields];
CListCtrl *pList=(CListCtrl*)GetDlgItem(%%1);//IDC_LIST_TABLEDATA
VERIFY(pList);
pList->DeleteAllItems();
for(index=0;index<countfields;index++)
{
var_index.vt=VT_I4;
var_index.IVal=index;
p_field=p_fields->Item[var_index];
bstr_field_name=p_field->GetName();
field_name=(LPCSTR)bstr_field_name;
Column[index]=field_name;
int ColumnWidth=Column[index].GetLength()*15;
pList->InsertColumn(index,field_name,LVCFMT_CENTER,ColumnWidth);
}

熱點內容
我的世界rpg伺服器背包位置 發布:2024-10-06 16:19:03 瀏覽:56
python的運行速度 發布:2024-10-06 16:19:02 瀏覽:803
怎麼看qq綁定了微信賬號密碼是什麼 發布:2024-10-06 16:04:41 瀏覽:772
安卓電視裝軟體對電視有什麼影響 發布:2024-10-06 16:01:54 瀏覽:440
編程廣播積木 發布:2024-10-06 16:01:42 瀏覽:88
聽音樂有緩存文件嗎 發布:2024-10-06 15:56:10 瀏覽:84
等級演算法 發布:2024-10-06 15:45:26 瀏覽:874
伺服器放上海還是北京雲主機 發布:2024-10-06 15:43:12 瀏覽:415
日常編程 發布:2024-10-06 15:43:02 瀏覽:327
生產任務量如何配置 發布:2024-10-06 15:40:39 瀏覽:196