Home > database >  The window of the pb extracted excel as a data source data
The window of the pb extracted excel as a data source data

Time:09-16

Pb window can't extract excel as a data source of data, I use the ODBC connection, to excel as a data source, data sheet for table window using the preview on the menu button to display the data, but in pb open control using dw_1. Retreve () to extract data, the Database transaction information not available. Call SetTrans or SetTransObject function, the dw_1. SetTransObject (sqlca), but useless, should be no connection to excel, please expert advice on how to write code to implement

CodePudding user response:

Above supplement: my email is: [email protected], QQ914955679 hope ace directions

CodePudding user response:

Connect using the sqlca;
Wrote this sentence

CodePudding user response:

String ls_sql ls_syntax, ls_error, ls_pathname='c: \ temp. XLSX', filepath, filename, ls_gb, ls_order
Long I, ll_row
String ls_where []


Gs_tran ls_tran
Ids_import=create datastore

GetFileOpenName (" Select File ", FilePath, FileName, "*. *", "EXCEL File (*. XLS; *. XLSX), *. XLS; *. XLSX, "GetCurrentDirectory (), 18)


Ls_tran=Create gs_tran

Ls_tran. DBMS="OLE DB"
Ls_tran. The AutoCommit=False

Ls_tran. DBParm="PROVIDER='12.0' Microsoft. ACE. The OLEDB., DATASOURCE='" + filepath +"', PROVIDERSTRING='12.0' Excel; HDR=YES; IMEX=1; MAXSCANROWS=1280;"

Connect using ls_tran;

Ls_error=ls_tran. Sqlerrtext

Ls_sql='select * from [sheet1 $]'

Ls_syntax=ls_tran. Syntaxfromsql (ls_sql, ' ', ls_error)

Ll_row=ids_import. Create (ls_syntax)

Ids_import. Settrans (ls_tran)

Ll_row=ids_import. Retrieve ()

If the sqlca. Sqlcode & lt;> 0 then
Messagebox (' prompt ', 'read the file failed, please check the sheet name or the program is running environment! ')
End the if

Disconnect the using ls_tran;

Destroy ls_tran

CodePudding user response:

The third floor of a see saved a lot of steps, are interested in?

CodePudding user response:

I have also seen your reply posts, probably similar to this, I tried the things too much, you save a lot of places I haven't read, of course I am a novice, just learn to write, but this kind of thinking method can write or draw lessons from, take the GetCurrentDirectory (), the function, for instance, is to direct assignment path or write a global function to the other path I tried all error, GetFileOpenName (" Select File ", FilePath, FileName, "*. *", "EXCEL File (*. XLS; *. XLSX), *. XLS; *. XLSX, "GetCurrentDirectory (), 18) this sentence is to can not find the GetCurrentDirectory ()
And this is it affirms beforehand, just right here, this is I can't,,,,,,,,

CodePudding user response:

reference 5 floor ycmk133 reply:
I have also seen your reply posts, probably similar to this, I tried the things too much, you save a lot of places I haven't read, of course I am a novice, just learn to write, but this kind of thinking method can write or draw lessons from, take the GetCurrentDirectory (), the function, for instance, is to direct assignment path or write a global function to the other path I tried all error, GetFileOpenName (" Select File ", FilePath, FileName, "*. *", "EXCEL File (*. XLS; *. XLSX), *. XLS; *. XLSX, "GetCurrentDirectory (), 18) this sentence is to can not find the GetCurrentDirectory ()
And this is it affirms beforehand, just right here, this is I can't,,,,,,,,


What version you are using pb, since pb8 is GetCurrentDirectory () this function

Import data from excel, there are two solutions
First, through the transaction object connected to excel, and then used to retrieve the data window, your problem is to connect to the database connection is successful, or an error in the connection

The second, can be connected through ole excel, then data replication, through importstring imported into the data window

CodePudding user response:



What version you are using pb, since pb8 is GetCurrentDirectory () this function

Import data from excel, there are two solutions
First, through the transaction object connected to excel, and then used to retrieve the data window, your problem is to connect to the database connection is successful, or an error in the connection

The second, can be connected through ole excel, then the data is copied out by importstring imported into the data window



Could you tell me how to set the second? The data is copied to the different data of different sheet in the window

CodePudding user response:

refer to 6th floor lzp_lrp response:
what are you using pb version, since pb8 is GetCurrentDirectory () this function

Import data from excel, there are two solutions
First, through the transaction object connected to excel, and then used to retrieve the data window, your problem is to connect to the database connection is successful, or an error in the connection

The second, can be connected through ole excel, then the data is copied out by importstring imported into the data window




The second kind of how to set? The numerical imported into different data of different sheet inside the window

CodePudding user response:

Deposit into a DBF bai

CodePudding user response:

refer to the eighth floor a847582843 response:
Quote: refer to the sixth floor lzp_lrp response:



What version you are using pb, since pb8 is GetCurrentDirectory () this function

Import data from excel, there are two solutions
First, through the transaction object connected to excel, and then used to retrieve the data window, your problem is to connect to the database connection is successful, or an error in the connection

The second, can be connected through ole excel, then the data is copied out by importstring imported into the data window




The second kind of how to set? The numerical imported into different data of different sheet window


Under the saveas method to save a specified path TXT file and then import the dw I usually do
  • Related