Get column names into a VB program, for an SQL query that joins tables
use [mydatabase]
select * from InvNum inum
left join _btblInvoiceLines ilin
on inum.autoindex = ilin.iinvoiceid
left join stkitem s
on ilin.istockcodeid = s.stocklink where InvNumber = 'IVQ0834' or InvNumber = 'IVQ0835'
I need to get out the column names in a VB program in the same order they would appear in the SQL query above...
I want to use something like:
select column_name from information_schema.columns where TABLE_NAME = ....
except there are several tables involved above so I dont know the format!
If you execute the query in your program using the SqlDataReader.ExecuteReader method, the column names will be available via the GetName method of the returned reader. But note that your query may return multiple columns with the same name.
Dim reader As SqlDataReader = command.ExecuteReader()
For x = 0 To reader.FieldCount - 1
Console.WriteLine(reader.GetName(x))
Next x
Dan Guzman, SQL Server MVP, http://www.dbdelta.com
Similar Messages
-
How to get column names for a specific view in the scheme?
how to get column names for a specific view in the scheme?
TIA
Don't have DD on the wall anymore....or this?
SQL> select text from ALL_VIEWS
2 where VIEW_NAME
3 ='EMP_VIEW';
TEXT
SELECT empno,ename FROM EMP
WHERE empno=10 -
Getting column names for a particular Table from Connection object.
Hi,
Can any one suggests me a way to get column names from a particular table of a database from the java.sql.Connection object. ?
Thanks in advance.Connection connection;
DatabaseMetaData metadata = connection.getMetaData();
String[] names = {"TABLE"};
ResultSet tables = metadata.getTables(null,"%", "%", names);
while (tables.next()) {
String tableName = tables.getString("TABLE_NAME");
ResultSet columns = metadata.getColumns(null, "%", tableName, "%");
while (columns.next()) {
String columnName = columns.getString("COLUMN_NAME");
} -
I have done extensive programming with the SQL Toolkit with LabVIEW versions through 6.1. My customer now wants to upgrade to Windows 7, so I am trying to upgrade to LabVIEW 2009 (my latest purchased version) using the Database Connectivity Toolkit, and the SQL Toolkit Compatibility vis. Everything seemed to be going okay with the higher level SQL operations, but I ran into trouble with the Get Column Name.vi.
The pictures below show the problem. The original SQL Toolkit connected the Prepare SQL.vi with the Get Column Name.vi with a cluster of two references, one for connection, and one for sql. The new compatibility vis have a class conflict in the wire because the Prepare SQL.vi contains a cluster with connection, and command references, but the Get Column Name.vi expects a cluster with connection and recordset references.
How do I resolve this conflict?
Thank You.
DanI've never worked with the old version of the toolkit, so I don't know how it did things, but looking inside the SQL prep VI, it only generates a command, and the the column name VI wants a recordset. I'm not super familiar with all the internals of ADO, but my understanding is that is standard - you only have the columns after you execute the command and get the recordset back. What you can apparently do here is insert the Execute Prepared SQL VI in the middle and that will return what you need.
I'm not sure why it worked before. Maybe the execute was hidden inside the prep VI or maybe you can get the column names out of the command object before execution. In general, I would recommend considering switching to the newer VIs.
Try to take over the world! -
Getting column names from cursor
Hi all
I have procedure which produces list of applied for jobs web page(using htp. package)
I got result in cursor, but have to provide dinamic sort, based on colimn pressed
procedure my_application_list
(pi_resume_num in varchar2 default null
,pi_sort_col in varchar2 default null
,pi_page_no in varchar2 default null
,pi_action in varchar2 default null
,pi_msg in varchar2 default null
is
CURSOR cur_job IS
SELECT jtl.JOB_TITLE
,jtl.COMPANY_NAME
,a.APPLY_DATE
,a.lang
,a.job_id
FROM job_tl jtl, applied_for_job a, gateway gt
WHERE a.job_seeker_id=app.job_Seeker
AND a.job_id=jtl.job_id
AND a.lang=jtl.lang
AND a.gateway=gt.gateway
AND jtl.lang=(SELECT substr(MIN(lt.order_list||jtl0.lang),2) lang
FROM job_tl jtl0
,language_tl lt
WHERE jtl0.job_id = a.job_id
AND jtl0.lang=lt.lang
AND lt.gui_lang=app.language)
ORDER BY pi_sort_col
rest of code
The columns displayed in web page are Job_title, Company_name and Applied_date
This page is displyed well, bu without column nmes at the top. I am trying to get column names from cursor in order to have ORDER BY <pi_sort_col>
can someone help how i can get those column names:Job_title, Company_name and Applied_date
User will be able to click on column and sort
Thank in advance .I appreciate any helpHi Francisco
Here is my code
CREATE OR REPLACE PACKAGE BODY cc_web_application_list
IS
TYPE COL_NAME_LIST IS TABLE OF VARCHAR2(100)
INDEX BY BINARY_INTEGER;
TYPE COL_ORDER_LIST IS TABLE OF VARCHAR2(30)
INDEX BY BINARY_INTEGER;
col_name_t col_name_list;
col_order_t col_order_list;
procedure my_application_list
(pi_resume_num in varchar2 default null
,pi_sort_col in varchar2 default null
,pi_page_no in varchar2 default null
,pi_action in varchar2 default null
,pi_msg in varchar2 default null
is
l_my_page_no PLS_INTEGER := TO_NUMBER(nvl(pi_page_no,1));
l_js_name gam_user.username%TYPE;
l_js_first_name gam_user.first_name%TYPE;
l_cnt PLS_INTEGER := 0;
l_scr_lines PLS_INTEGER := 0;
l_curline PLS_INTEGER;
l_jobs_applied PLS_INTEGER;
l_total_rec PLS_INTEGER;
l_total_pages PLS_INTEGER;
l_pos PLS_INTEGER;
l_first PLS_INTEGER :=0;
last PLS_INTEGER :=0;
l_lines PLS_INTEGER := 10;
col_name VARCHAR2(100) := col_name_t(3) ;
col_order VARCHAR2(30) := 'DESC';
str VARCHAR2(2000);
TYPE display_rec IS TABLE OF VARCHAR2(500) INDEX BY BINARY_INTEGER;
display display_rec;
TYPE page_table_type IS TABLE OF PLS_INTEGER INDEX BY BINARY_INTEGER;
page_number page_table_type;
CURSOR cur_job IS
SELECT jtl.JOB_TITLE job_title
,jtl.COMPANY_NAME company_name
,a.APPLY_DATE apply_date
,a.lang
,a.job_id
FROM job_tl jtl, applied_for_job a, gateway gt
WHERE a.job_seeker_id=app.job_Seeker
AND a.job_id=jtl.job_id
AND a.lang=jtl.lang
AND a.gateway=gt.gateway
ORDER BY a.apply_date;
This decode is a problem
decode(col_order,'ASC'
,decode(col_name
,col_name_t(1), jtl.job_title
,col_name_t(2), jtl.company_name
,col_name_t(3), TO_CHAR(a.apply_date, 'YYYYMMDDhh24miss')
,a.apply_date)
) ASC
,decode(col_order,'DESC'
,decode(col_name
,col_name_t(1), jtl.job_title
,col_name_t(2), jtl.company_name
,col_name_t(3), TO_CHAR(a.apply_date, 'YYYYMMDDhh24miss')
,a.apply_date)
) DESC
,a.apply_date
TYPE rec_one IS TABLE OF cur_job%ROWTYPE INDEX BY BINARY_INTEGER;
r rec_one;
BEGIN
BEGIN
SELECT username,first_name
INTO l_js_name,l_js_first_name
FROM gam_user
WHERE user_id = App.job_seeker;
EXCEPTION
WHEN OTHERS THEN NULL;
END;
Cc_Pkg_Elements.p_page_top_job_seeker(
'Personal Job List'
,REPLACE(Txt_Proc_My_Joblist.title_job_list
,'##first_name##',l_js_first_name),'N' ,TRUE ,'Pxx');
----- get numer of records returned by query
SELECT COUNT(1)
INTO l_total_rec
FROM job_tl jtl,applied_for_job a
,gateway gt
WHERE a.job_id = jtl.job_id
AND a.job_seeker_id = App.job_seeker
AND a.gateway = gt.gateway ;
------get number of pages
l_total_pages:=CEIL (l_total_rec/l_lines);
l_jobs_applied := 0;
col_name := pi_sort_col;
col_order := pi_sort_col;
--get first positions
l_first := (nvl(l_my_page_no,1) - 1) * l_lines + 1;
FOR rec IN cur_job LOOP
l_cnt := l_cnt + 1;
EXIT WHEN l_cnt > l_first + l_lines - 1;
IF l_cnt >= l_first THEN
l_scr_lines := l_scr_lines + 1;
r(l_scr_lines) := rec; --assign counter from loop to r index
IF rec.apply_date IS NOT NULL THEN
l_jobs_applied := l_jobs_applied + 1;
END IF;
END IF;
END LOOP;
htp.p('<FORM ACTION="'||App.gateway||'8.my_application_list" METHOD="post">');
htp.p('<table align="center">');
htp.p('<tr><td>');
IF r.COUNT = 0 THEN
Web_Pkg_Elements.doc_msg(Txt_Proc_My_Joblist.no_jobs);
END IF;
htp.p('</td></tr>');
htp.p('</table>');
--table_heading(col_name ,col_order );
htp.p('<table align=center>');
htp.p('<tr align="center"><td>');
FOR i IN 1..l_total_pages LOOP
page_number(i) := i;
IF page_number(i) = l_total_pages THEN
htp.p('');
||'');
Web_Pkg_Elements.doc_val_small(page_number(i)||'</A>');
ELSE
htp.p('');
|'||'');
Web_Pkg_Elements.doc_val_small(page_number(i)||' |'||'</A>');
END IF;
END LOOP;
htp.p('</td></tr>');
htp.p('</table>');
htp.p('<table align=center>');
FOR l_curline IN 1..l_scr_lines LOOP
display(1) := NVL(r(l_curline).job_title, '<br>');
display(2) := NVL(r(l_curline).company_name, '<br>');
display(3) := NVL(Cc_Pkg_Nls.date2char(r(l_curline).apply_date, App.date_format), '<br>');
IF MOD(l_curline, 2) = 0 THEN
Cc_Pkg_Elements.tr_even;
ELSE
Cc_Pkg_Elements.tr_odd;
END IF;
htp.p('<td>');
htp.p('');
Web_Pkg_Elements.doc_val(display(1)||'');
htp.p('</td>');
htp.p('<td>');
Web_Pkg_Elements.doc_val(display(2));
htp.p('</td>');
htp.p(' <td>');
Web_Pkg_Elements.doc_val(display(3));
htp.p(' </td>');
htp.p('</tr>');
END LOOP;
htp.p('</TABLE>');
htp.p('<TABLE width="88%" BORDER="0" CELLPADDING="0" CELLSPACING="0"
align="center">');
htp.p('<tr valign=bottom>');
htp.p('<TD colspan=2 align=right>');
IF l_my_page_no > 1 THEN
htp.p('<P>'||'<IMG SRC="'||App.image||'prev.gif" ALT="'
||Txt_Proc_My_Joblist.prev
||'"' ||' HEIGHT=20 BORDER=0 ALIGN=bottom '
||'hspace=2>');
END IF;
IF l_my_page_no < CEIL (l_total_rec/l_lines) THEN
htp.p(' <a href="'||
web_pkg_elements.link$$(App.gateway||'8.my_application_list?'
||'pi_sort_col='||Web_Pkg_Elements.replace_in_url(pi_sort_col)
||'&pi_msg=&pi_page_no='||TO_CHAR(l_my_page_no + 1)
||">'||'<IMG SRC="'||App.image||'next.gif" ALT="'
||Txt_Proc_My_Joblist.NEXT
||'"' ||' HEIGHT=20 BORDER=0 ALIGN=bottom '
||'hspace=2></a>');
END IF;
htp.p('</TD>');
htp.p('</TR>');
htp.p(' </TABLE>');
htp.formHidden('pi_sort_col', pi_sort_col);
htp.formHidden('pi_page_no', pi_page_no);
htp.p('</FORM>');
END my_application_list;
END ; --cc_pkg_application_list -
How to use get column name.vi in SQL toolkit 2.0?
Due to the vi "get column name.vi" paremeters,no table name has connected to the vi. So, I want to ask how to use this vi for gain one column name of a table. Maybe there are some other ways to solve column name getting.
Thanks.Thanks!
Error 4101 Description:
Execute SQL - The connection, statement, or query handle you provided is not valid.
I don't just used the toolkit in a while,now, I am developing a irrigation system. For the table field names defined by users,column names must be known before any select operations. Do you have any other good idea about drawing out the columnname parameters?
As you know, a valid DSN and table have been also available. The database I used is Access. The bad thing to me is that there is no any text information gotten. And I think, it may be some problems in connection way which I don't find out.
Really appreciated by your reply.
Could you give me some example in the aspect?
Thank you again. -
I have purchased Adobe XI Pro and created a form for entering bowling scores to submit to newspaper for my high school team. I can not figure out how to get pdf's into my documents folder on my iPad so that I can access the files in bowling alleys where I do not have a Wi-Fi connections. I need to be able access files without going to acrobat.com. Help!!!@
Post the PDF files to a web site. The browse to them in Safari on the iPad. When you Open the files specify the Open to occur in Adobe Reader. Then you can have/Save them in your Documents folder on the iPad. An iPad has limited access to files otherwise.
-
Getting column names using EJB3.0
Hi,
Could someone help me how to get column names in EJB3.0.
I am having reference to folloiwng ejb.
@Entity
@Table(name = "users")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
@SequenceGenerator(name = "users", sequenceName = "users")
public class User {
private Long userId;
private String username;
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "users_seq")
@Column(name = "user_id")
public Long getUserId() {
return userId;
public void setUserId(Long userId) {
this.userId = userId;
@NotNull
@Column(name = "username")
public String getUsername() {
return username;
public void setUsername(String username) {
this.username = username;
Thanks in advanceYou shouldn't be getting column names from EJBs.
You need to know the object, the schema, and how to map one to the other.
So you should look at the SQL table "users" and map this object to it.
% -
WRAP JTable Column Name into 2 lines
I have a JTable with a long column Name. Can I wrap the Column Name into multiple (2) lines.
baskaraninfo wrote:> set the following to a table column,<html><body>Employee<br>Name</body></html>>The break tag got lost cos you didnt use the code tags
<html><body>Employee<br>Name</body></html> -
Getting column names empty from MS Access database
Hi,
I have MS Access intalled in my desktop.I am using aveConnect jdbc driver to connect to MS Access database.
I am trying to retrieve all the table name and column names of respective tables .
But when i get column name as empty string when i try to retrieve the column name of a table.
here is the sample code i use.
I am getting the column count of a particular table and type of the column.
It would be nice if some could help me .
ResultSet ColumnData = meta.getColumns(null, null, "TBLACCOUNT", null);
System.out.println( "ColumnData:" +ColumnData);
if (ColumnData!= null) {
System.out.println("ColumnData not null");
ResultSetMetaData rsmd = ColumnData.getMetaData();
int columnCount = rsmd.getColumnCount();
String columnName = rsmd.getColumnName(1);
String columnType = rsmd.getColumnTypeName(1);
System.out.println("columnCount is " +columnCount);
System.out.println("The name of the first column is: " +columnName);
System.out.println("The data type of the first column is: " +columnType);
thanks
sheebaYou're here in a JDBC forum, not a SQL forum. I suggest you to start learning SQL and come back once you have JDBC issues.
Here is a list of links to all SQL tutorials available on the Internet.
http://www.google.com/search?q=sql+tutorial -
Jakata POI excel: get column name
Hi All
Is there a way I can get column name where a particular cell is: (In excel spreadsheet)
Ex: If I have column number 2: I should get "C" ( given col numbers are 0 based).
Please let me know.
Thanks
bibIt's not as easy as it might seem, since the letter sequence system is not compatible with common numeric sequence system.
See here:
[Java, POI - Converting number to Excel columns letter names|http://ondra.zizka.cz/stranky/programovani/java/converting_number_to_excel_column_letters_name.texy] -
Why is Mail asking me for the name of an smtp server for an email address that doesn't exist?
I've migrated from Snow Leopard to Mountain Lion on a new Mac, but in trying to use Mail on ML, it keeps asking me for the name of an smtp server for an email address that's never existed. The addy has my user name correct, but the server part of the address doesn't exist, or at least I've never used an email address with that provider. On ML there's no plist file for Mail, so nothing to delete there. What else can I do to get Mail working? The only other option I have is to abandon Mail as being crippled and useless, and use Postbox, which for it's price (US$9.95) is an attractive option. OTOH, I've paid for Mail after all, so it really ought to work. Any clues as to what I can do to stop its nonsensical behaviour? How do I file a bug report?
TIA.
PaulineAmasis wrote:
On ML there's no plist file for Mail, so nothing to delete there.
~/Library/Containers/com.apple.mail/Container.plist
(Go to your Finder "Go" menu hold the option key to choose "Library", since the ~/Library is hidden on ML) -
How to pass a variable for a SQL query in OLEDB source?
Hi All,
I am new to SSIS and working on it past few days. Can anyone please help me getting through a scenario where I need to pass a variable in the SQL statement in OLEDB source connection. Please find below for the details.
eg:
1) I have a SQL table with the columns SerialNumber, Name, IsValid, FileName with multiple rows.
2) I have the file Name in a variable called Variable1.
3) I want to read the data from my SQL table filtering based on the FileName (Variable1) within a data flow task and pull that data to the destination table.
Question: In the data flow task, added source and destination DB connection with a script component in between to perform my validations. When trying to retrieve the data from source using the variable (i.e. SQL Query with variable), I am not able to add
the query as the SQL statement box is disabled. How to filter the data based on the variable in the source DB ?
Any help/suggestions would be of great help.
Thanks,
SriJust to add with Vaibhav comment .
SQL Command : SQL query either with SQL variable or any condition or simple Sql statement
Like ;
Select * from dimcustomer
SQL Command using Varible :
Sometimes we design our dynamic query in variable and directly use that variable name in oledb source.
If you Sql query needs a condition based on SSIS variable .
you can find a Example here :
http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/01/17/ssis-replace-dynamic-sql-with-variables.aspx
http://www.select-sql.com/mssql/how-to-use-a-variable-inside-sql-in-ssis-data-flow-tasks.html
Thanks
Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com -
1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed in the stat plan ?
2. Does rowsource statistics gives some kind of understanding of Extended stats ?You can get Row Source Statistics only *after* the SQL has been executed. An Explain Plan midway cannot give you row source statistics.
To get row source statistics either set STATISTICS_LEVEL='ALL' in the session that executes theSQL OR use the Hint "gather_plan_statistics" in the SQL being executed.
Then use dbms_xplan.display_cursor
Hemant K Chitale -
Hi All,
I am looking for an SQL query to request the HDS database to find out which Directory Number / instrument was associated with a specific CTI OS agent login ID.
Has anyone done such a query before ?
Thanks and Regards
NickHi,
this should work in 8.0 and 8.5:
SELECT
ag.PeripheralNumber AS [LoginID],
al.Extension,
al.LogoutDateTime
FROM [instance]_hds.dbo.Agent_Logout al
JOIN [instance]_awdb.dbo.Agent ag ON al.SkillTargetID = ag.SkillTargetID
Of course, replace [instance] with the ICM instance.
The query returns a table with three columns, first is the login ID aka PeripheralNumber, Extension is... well, the agent's extension, and LogoutDateTime is the timestamp when the agent logged out.
G.
Maybe you are looking for
-
NW 7.01 stack 6 compatiblity with PI 7.0
Hi, We planned to apply NW EHP1 stack 6. We are currently using component version SAECC 6.0 with kernel 7.00 support package 18. At the same time, we are using PI 7.0 support package 18. So, I planned to update PI to the latest level. So, should I go
-
Multiple Photoshop versions installed (CC and CC 2014) - safe to delete the oldest?
I'm running out of disk space and noticed that Creative Cloud actually has installed *two* versions of Photoshop CC: 1) Adobe Photoshop CC - 1.2GB, last modified 21 Dec 2013 2) Adobe Photoshop CC 2014: 1.65GB, last modified today I'm *almost* sure th
-
CS 1.0 for XP to Windows 7
Is there a way to make CS 1.0 (Designed for XP) to work for Windows 7?
-
Tracks missing with exclamation mark but in the cloud!!
For whatever reasons I am now missing at least 1000 tracks as each has beside it an exclamation mark inside a circle. If I open the track it asks that I locate or cancel - if I choose the latter it plays the track because it is is the cloud. I then h
-
File sharing is sharing ALL my files across my network
I have a regular router/modem provided by my ISP. I have an iMac connected to the router via ethernet. I also have a Macbook connected to the gateway via wireless. When I turn File Sharing ON on my iMac, it doesn't just share my "Public Folder" like