How do you get the column names for a given table from an SQL LocalDB programmatically in Visual Basic.
Just new to this and unable to find answers
My solution
Public Function GetTableColumnNames() As Boolean
Form1.ListBox1.Items.Clear()
_MDFFileName = String.Format("{0}.mdf", _DatabaseName)
_sqlConnectionString = String.Format("Data Source=(LocalDB)\v11.0;AttachDBFileName={1};Initial Catalog={0};Integrated Security=True;", _DatabaseName, Path.Combine(_DatabaseDirectory, _MDFFileName))
Dim cn As New SqlConnection(_sqlConnectionString)
'put the table name in brackets in case it has spaces in it
Dim SQLString As String = "SELECT * FROM [" & _TableName & "]"
Try
cn.Open()
Dim cmd As New SqlCommand(SQLString, cn)
Dim rdr As SqlDataReader =
cmd.ExecuteReader(CommandBehavior.KeyInfo)
Dim tbl As DataTable = rdr.GetSchemaTable
'This shows all of the information you can access about each column.
For Each col As DataColumn In tbl.Columns
Form1.ListBox1.Items.Add(col.ColumnName)
Debug.Print("col name = " & col.ColumnName & ", type = " & col.DataType.ToString)
Next
'Get each column.
For Each row As DataRow In tbl.Rows
Form1.ListBox1.Items.Add(row("ColumnName"))
Next
rdr.Close()
Catch
MessageBox.Show("Error opening the connection to the database.")
Finally
cn.Close()
End Try
Return _Success
End Function
Similar Messages
-
C Programming: How can we get the filesystem name for a given file-path?
C Programming: How can we get the filesystem name for a given file-path?
Say I have a filepath=/mnt1/file1
Using some OS API like stat, can I get the Filesystem /mnt ?
Thanks in advance,
-VEnter the command up to the point of entering the file path and add a space, then drag the file into the terminal window. It will fill out the path.
If you need to go further into the contents of the Application package, you can continue with /Contents...
Another way is to start typing and then hit Tab to auto-complete. It will stop where it can't determine the next letter.
So, type /App tab and it will fill in /Applications. Type a / and start with the name of the app, then tab and it should complete. Continue till you have the correct path.
Spaces will be replaced with \<space>, so, App Store would end up as /Applications/App\ Store.app -
Hi ,
I have a table so many constraints on so many columns. I need to know which column has which constraint plsql dev?? like below...
table_name -------- col_name ------ constraint_name_of_that_col
xxxxxx xxxxxxx xxxxxxxxxxxxxxxx
or else please let me know how can i get the corresponding col_name for a particular constraint name???My be this can give you a help:
[code]
SELECT *
FROM ALL_CONSTRAINTS
WHERE R_CONSTRAINT_NAME IN (SELECT CONSTRAINT_NAME
FROM ALL_CONSTRAINTS
WHERE TABLE_NAME = 'TABLE_NAME'
[/code] -
How to add get the field name for a newly added site column.
I have the following:-
Enterprise wiki site collection inside SharePoint server 2013.
I added a new site column of type managed metadata.
I opened the enterprisewiki.aspx page layout using the SP designer, to add the newly added site column to it.
But I have noted that to add any site column I need to know the field name , for example the default wiki category column is referenced inside the page layout as follow:-
<Taxonomy:TaxonomyFieldControl FieldName="Wiki_x0020_Page_x0020_Categories" EmptyValueDescriptionForTargetTemplate="<%$Resources:cms,enterwiki_nocategories_assigned%>" DisableInputFieldLabel="true" runat="server"/>
<b>
So my question is how I can know the field name for my newly added site column?
Thanks in advance for any help.
RegardsHi,
The “FieldName” should be the internal name of the column, you will find it at the address bar at the “Site Columns”->”Edit Column” page:
Best regards,
Patrick
Patrick Liang
TechNet Community Support -
Hi,
I am using OCCI to interact with DB through code, which means I am writing a vc++ file to interact with Data Base and execute the Stored Procedure which I am calling from the C++ Code. And also displaying the output of the Stored Procedures to the Front End. I am succeeded in this, but now I should be able to display the Column names of the output to Front End. Can any one help me on this.
Example:
Sno | Sname
------- |-------------
1 ABC
2 DEF
I am getting (1,ABC) and (2,DEF) as the output of the Stored Procedure but I need the Column names also to display. How to get them.
Thanks in Advance..:)Look at Re: exporting csv via pl/sql - select statement?
It has an example how to extract the column name from a cursor. You have to check, whether you can use DBMS_SQL.DESCRIBE_COLUMNS
Your procedure might need another out parameter, that returns the column names , e.g. as comma separated list or as varray. -
How can i get the column names in CSV file.
Hi,
After execution of infospoke i can not see the column names in that file.How can i get column of respective infoprovider?
Thanks,
Gananadha LenkaHello Gana,
Actually while exporting the data using Info Spoke, we have the possibility to modify the data that we send. This is possible using transformations.
In your Info Spoke, you have a tab called Transformations.
Here you need to create an implementation and then use BADi to populate data.
Check if you can write a start routine sort of thing here and insert a new record into the internal table by hardcoding with your field headings.
Let me know if you dont know how to create transformations.
Kris... -
How do I get the trial version for Photoshop CS6 extended from the Creative Cloud Trial
Hello ...
Plz I wanted to downlad the trial version of Photoshop CS6 Extended and I followed this link
http://www.adobe.com/cfusion/tdrc/index.cfm?product=photoshop&loc=en_us
Then I chose this option : Option 2: Join Creative Cloud and download now (Recommended - it's free)
Then the adobe application manager has been installed and the photoshop CS6 started to be installed automaticaaly and after it done , I found it the standard version not the Extended ... So how and where can I get the Extended version for both 32 bit and 64 bit?
Your prompt reply is highly appreciated
Thank you ....So if you download the trial from the trial page at http://www.adobe.com/cfusion/tdrc/index.cfm?product=photoshop you get Photoshop CS6 Extended. When you then remove the trial and reinstall from the Adobe Application Manager with your trial Creative Cloud you only see the Standard version?
If this is so you can try reviewing your installation logs by following the steps listed in Troubleshoot with install logs | CS5, CS5.5, CS6 - http://helpx.adobe.com/creative-suite/kb/troubleshoot-install-logs-cs5-cs5.html. Although your 30 day trial has already begun. I would recommend for now you just remove the installation and install from the trial page so that you can try the extended features. -
How do I get the album artwork for digital booklets purchased from itunes?
I have all these digital booklets but when I look at the album artwork viewer I don't see any artwork for for digital booklets. What kind of artwork is there supposed to be there and how do I get it?
CDs don't contain artwork, Both iTunes and WMP download the artwork from online sources, in the case of iTunes it comes from the iTunes Store (if the album is available in the store). If the artwork isn't available in the store you can add a suitable artwork image manually. You'll get information on both methods at this link: iTunes for Windows - Adding artwork to songs and other items
If you can't find the album covers you want from iTunes you can get them from various other sources. I find this site is a good source of artwork: CD/Album Cover Art Search from SlothRadio.
Another place for finding suitable artwork is to go to Amazon. You can also locate artwork using Google image search and put the artist or album name. Locate the album from any of those sources, right click on the image and save it to the desktop, once it's there drag it to the iTunes artwork pane. Once you've added the artwork you can either delete the original file or keep it in a folder somewhere in case you need to use it again. Alternatively there are programs like these that help locate artwork: iTunes Art Importer or MP3 Tag
If you have a scanner you can create your own artwork files by scanning the CD cover itself, this is particularly useful when you are dealing with rare recordings. -
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");
} -
How do you get the product key for your new Satellite C55-B5202?
I recently bought this new laptop and for the love of God I can't use Microsoft Office cause it keeps asking me for a product key. Please tell me how do I retrieve it! It did not come with a CD, there is no sticker at the bottom of the laptop or the box itself.
Solved!
Go to Solution.Satellite C55-B5202
According to the spec above, you have a "1 month trial for new Office 365 customers." When the trial ends, you’ll be prompted to choose which version of Office you want to purchase.
Microsoft Office has never been free.
-Jerry -
Getting the column names dynamically
hi gurus,
i have list item populated with many table names from a schema.
i have grid in oracle forms 10g and i want to fill the grid with the data that should come at least four/more columns.
i want to fire the list change trigger when each time any one table name is selected/changed.
how can i get the column names dynamically
please give me the step by step process
for filling the grid..hi ,
by getting column names dynamically i am creating a record group
using this below query
SELECT COLUMN_NAME, DATA_TYPE FROM USER_TAB_COLUMNS WHERE TABLE_NAME = <table_name>
but when timestamp datatype is there then it is showing error cannot create group groupname
but the record group is running successful on varchar2,number,date dayatypes
if any alternative is there i mean to say without using record group then tell me or where is the problem -
How to get the column names of the table into the Dashboard prompt
how to get the column names of the table into the Dashboard prompt
Thanks & Regards
Kishore PHey john,
My requirement is as follows
I have created a Rank for Total sales by Region wise i.e RANK(SUM(Dollars By Region)) in a pivot table.
My pivot table looks like this
COLUMN SELECTOR: TOTAL US , REGION , DISTRICT , MARKET
---------------------------------------------------- JAN 2009 FEB 2009 MAR 2009
RANK REGION DOLLARS DOLLARS DOLLARS DOLLARS
1 CENTRAL 10 20 30 40
2 SOUTHERN 10 30 30 70
3 EASTERN 20 20 20 60
4 WESTERN 10 20 30 40
When i select the District in column selector
Report has to display rank based on Total Sales by District. i.e
------------------------------------------------- JAN 2009 FEB 2009 MAR 2009
RANK DISTRICT DOLLARS DOLLARS DOLLARS DOLLARS
for this i need to change the fx of rank i.e RANK(SUM(Dollars By Region)) to RANK(SUM(Dollars By District)) and fx of Region i.e Markets.Region to Markets.District dynamically.
so , i need to capture column name of the value selected from the column selector and dynamically i need to update the fx 0f RANK & fx of region.
do you have any solution for this?
http://rapidshare.com/files/402337112/Presentation1.jpg.html
Thanks & Regards
Edited by: Kishore P on Jun 24, 2010 7:24 PM
Edited by: Kishore P on Jun 24, 2010 7:28 PM -
Reading csv file how to get the Column name
Hi,
I am trying to read a csv file and then save the data to Oracle.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:;Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=.;Extensions=csv,txn");
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("select * from filename.csv");
while(rs.next())
System.out.println(rs.getString("Num"));
My csv file looks like this:
"CHAM-23","COMPANY NAME","Test","12",20031213,15,16
Number,Environ,Envel,Date,Time
"1","2",3,"4",5
"6","7",8,"9",9
Now is there anyway using the above code I start processing the file from the second row that holds the names of the columns and skip the first row. And also can I get the name of the column using ResultSet something like:
if columnName.equals("Number")
Because I may have a csv file that could have more columns:
"CHAM-24","COMPANY NAME","Test","12",20031213,16,76
Number,Environ,Envel,Date,Time,Total,Count
"1","2","3","4","5",3,9
"6","7","8","9",9",,2
So I want to get the column name and then based on that column I do some other processing.
Once I read the value of each row I want to save the data to an Oracle Table. How do I connect to Oracle from my Application. As the database is on the server. Any help is really appreciated. ThanksThe only thing I could think of (and this is a cluj) would be to attempt to parse the first element of each row as a number. If it fails, you do not have a column name row. You are counting on the fact that you will never have a column name that is a number in the first position.
However, I agree that not always placing the headers in the same location is asking for trouble. If you have control over the file, format it how you want. If someone else has control over the file, find out why they are doing it that way. Maybe there is a "magic" number in the first row telling you where to jump.
Also, I would not use ODBC to simply parse a CSV file. If the file is formatted identically to Microsoft's format (headers in first row, all subsequent rows have same number of columns), then it's fine to take a shortcut and not write your own parser. But if the file is not adhering to that format, don't both using the M$ ODBC driver.
- Saish
"My karma ran over your dogma." - Anon -
How to get the owner name for the file in ftp using abap ?
Hi folks ,
How to get the owner name for the file in ftp using abap ? please help me very ugernt . I tried with all standard FTP commands
but doest work out me . Helping in this regard highly appreciated ...
Thanks and regards,
Swarupa VanarchiHi
dont you have used the os user while calling the FTP_CONNECT FM?
Hope you are not talking about the user executing the FTP program.
Else If you are talking about the FTP file creator then its not related to abap as you can handle it by maintaining the user in file name itself.
May be i am going too far with if and elses here as your question possesses no clarity.
Plz elaborate your requirement before anybody can help.
Regards
sateesh -
C# : Get Column name for an Insert Query from The Selected GridView Row.
Hi Guys, I am trying to insert data in an SQL table by executing an Insert Query.
The problem is that I need to get the column name from a cell in the selected gridview Row.
Here's the snippet:
SqlCommand cmd30 = new SqlCommand("insert into mytable ( '"+GridView7.SelectedRow.Cells[0].Text+"' , r_id) values ('"+ GridView7.SelectedRow.Cells[1].Text +"', '"+TextBox1.Text+"')",con30);
cmd30.ExecuteNonQuery();
**r_id is not a Primary Key.
The Error is get is:
Incorrect syntax near 'r_id'.
Any Help will be appreciated.
Thanks,
Shaleen
TheHexLordHi TheShaleen,
Like your title mentioned.GridView control is a web class.This forum is to discuss problems of C# development. Your question is not related to the topic of this forum.
You'll need to post it in the dedicated ASP.Net Forum for more efficient responses, where you can contact ASP.NET experts. Thanks for understanding.
Best regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Maybe you are looking for
-
Songs are in reverse order on iPad, but correct on iTunes
I have a number of Smart Playlists that look fine when displayed on iTunes, but when iTunes copies them to my iPad Air, the list of albums shows up in the correct order but the songs in each album are sorted in reverse order. So for example, I have a
-
Can't sync home videos to iphone 5, iTunes 11.1.4
Hi, For some reason, after successfully doing this many times (I already have some home videos on my iphone 5), when I sync a 7 minute home video in 720p H264 quicktime movie format from itunes to my iphone 5, it does not appear on the iphone 5 under
-
W7 client machine stuck on startup "Group Policy Files Policy"
we have some w7 machine getting stuck on boot up before ctrl-alt-del, once verbose message was turned on for troubleshooting, we noticed they were stuck at "applying group policy files policy". we had let it wait for more than 60 minutes at time and
-
Apache starts but will not display tn browser
I can start Apache using Terminal but I can not serve up a html page. Not sure why. OS X 10.9 greg
-
"Left Behind" by Flash Player lately (although by Illustrator and PhotoShop earlier)
Adobe and Apple need to be more supportive of older systems and use of older software that one uses for special applications. I need to use Classic periodically and have to do my "gymnastics" in order to accomplish things that current or slightly ear