Retrieving Field Names Using VB
Hi guys,
does any of you know how to use VB to retrieve (into txt files) the field names of the table from the server database?
'coz currently I'm writing them myself manually (e.g. field_names = "ID, Score, Grade") and some tables have ridiculously a lot of fields so it's kinda very very troublesome to write the names manually.
Thx heaps
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Retrieving Names From Taskbar
Is there a way I can have an array called aTaskbar() and get the names of all the programs open through the taskbar and store them in the array?
Sql Query: Retrieving Two Names
Here's my problem: I have 2 table namely Names and Partners. In NAMES i have fields Id, Lastname and Firstname. In PARTNERS I have Id, Name1 and Name2. In Partners.Name1 and Partners.Name2, the values are the unique Id from NAMES. So how can I retrieve this two names in a single query and display the lastnames and firstnames in the listbox. The output is like this:
Quote:
listbox:
Martin, John and David, Mary
I tried already some code with multiple queries and it became so complicated. Please help me.
Retrieving File Names
I have created a VB program a while ago and now I am making a few ajustment to it. One thing that I would like to change is the File Retrieve function that I have. Currently the user types in the location of the files in a text box. What I would currently like to do is make the driveListBox, so that the user can just go in there click on the drive, select the folder and then the files that need to be used. This is sort of like all the opens in windows now. I know that this is possible but dont have enough knowledge to create this my self.
Anyone Who knows anything about this please help me out.
Please provide code if possible.
Thanks
Help With Retrieving File Names.
I am having a hard time finding some information on how to get file names into strings.
What I want is to search a folder on my hard drive (ie...C:programs raining) to find all the files of a certain extension (ie... *.cor). As the files are found, I want to set the file name to a string variable array and count the amount of files with that extension.
Can anyone help me?
Retrieving Table Names
I'm using adodb throughout my app so far but that doesn't mean I have to keep that way (although I do need to keep using ODBC DSN Connection strings, not references to filenames).
I'm trying to get hold of all the user table names in my (Access) database.
If I go into Access and run an SQL query of
Code:
"SELECT Name FROM msysobjects WHERE (type = 1) AND (flags = 0) ORDER BY name;"
I get all the table names, as expected. But if I try it in VB, as in
Code:
' adoSearch has been Dim'd As New adodb.Recordset elsewhere
Dim db As ADODB.Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=CARS;uid=cars;pwd=cars;"
' Open with SQL
adoSearch.Open "SHAPE {SELECT Name FROM msysobjects WHERE (type = 1) AND (flags = 0) ORDER BY Name}", db, adOpenStatic, adLockPessimistic
' ...
I get runtime error -2147217911 (80040e09):
Record(s) cannot be read; no read permission on 'msysobjects'. And the adoSearch.Open line is highlighted.
What's wrong with that? Why can't I do it in VB if it works in Access?
Is there another better/easier/working way to do it? I presume this isn't an obscure thing to do!
Thanks all,
AndyC
London
------------------
* * * * * * * * * * * * * * * * * * * * * *
* *
* AndyC *
* London *
* email: andy.collyer@bigfoot.com *
* *
* * * * * * * * * * * * * * * * * * * * * *
Retrieving Table Names
I'm using adodb throughout my app so far but that doesn't mean I have to keep that way (although I do need to keep using ODBC DSN Connection strings, not references to filenames).
I'm trying to get hold of all the user table names in my (Access) database.
If I go into Access and run an SQL query of
Code:
"SELECT Name FROM msysobjects WHERE (type = 1) AND (flags = 0) ORDER BY name;"
I get all the table names, as expected. But if I try it in VB, as in
Code:
' adoSearch has been Dim'd As New adodb.Recordset elsewhere
Dim db As ADODB.Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDataShape;Data PROVIDER=MSDASQL;dsn=CARS;uid=cars;pwd=cars;"
' Open with SQL
adoSearch.Open "SHAPE {SELECT Name FROM msysobjects WHERE (type = 1) AND (flags = 0) ORDER BY Name}", db, adOpenStatic, adLockPessimistic
' ...
I get runtime error -2147217911 (80040e09):
Record(s) cannot be read; no read permission on 'msysobjects'. And the adoSearch.Open line is highlighted.
What's wrong with that? Why can't I do it in VB if it works in Access?
Is there another better/easier/working way to do it? I presume this isn't an obscure thing to do!
Thanks all,
AndyC
London
------------------
* * * * * * * * * * * * * * * * * * * * * *
* *
* AndyC *
* London *
* email: andy.collyer@bigfoot.com *
* *
* * * * * * * * * * * * * * * * * * * * * *
Retrieving Table Names From Mdb
Hello VBcitizens,
I'm a bit fresh at working with databases in VB,
I'm making a simple .mdb reader, I'm working with MS-ADO & MS-Datagrid controls,
after i select a database i want to retrieve a list of the tables that are in the database.
I couldn't findout how i can retrieve the table names, this is what i got so far;
How can i do this? thanks at front.
Code:
Option Explicit
Private sDB As String
Private Sub TpmOpen_Click()
CDLG.FileName = ""
CDLG.Filter = "MDB Files (*.mdb)/*.mdb"
CDLG.DialogTitle = "Open Database"
CDLG.ShowOpen
If Not CDLG.FileName = "" Then
sDB = CDLG.FileName
'retrieve a list of tables and add into a ComboBox
End If
End Sub
Private Sub Combo1_Click()
Open_MDB sDB, Combo1.Text
End Sub
Private Sub Open_MDB(sFileName As String, sTableName As String)
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data " & _
"Source=" & sFileName & _
";Persist Security Info=False"
Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = sTableName
Adodc1.CursorLocation = adUseClient
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
End Sub
Retrieving Table Names(newbie)
Hi,
What I would like to do is this:
I have a database(database1)
I have tables with various names that follow a naming convention.
ie. 3VSheaves, 5VSheaves, 8VSheaves, 3VBelts, 5VBelts, 8VBelts, MotorShafting, MotorFrame
What I would like to is be able to retrieve the names of the tables in the database, search them and extract information from the table name to present to the user in a combobox.
ie. the combobox would have a list containing 3V, 5V, and 8V, based on a search done to the table names looking for the word "Sheaves". I could then formulate my select statement based on the user input which would populate a secondary combobox with a field from the corresponding table.
This would allow me to enter new Sheave information to the database and not have to update my code(If I were to hard code it as a table name for SQL statement purposes). I looked at the tabledef object, but I do not understand it. I also looked at all the ado tutorials referred to on the site.
I hope I was clear with my situation. Any help would be greatly appreciated.
p.s. Sheaves and Belts are used to transmit power from two shafts that have parrallel axes, like the belts in your car.
Retrieving All Methods/functions Names
Is this possible? Lets say i have a module where i have for example 500 methods/functions. Now i would like to loop through this complete module (at runtime) and place their names into array. Any ideas?
Need Help Retrieving Nested Group Names
Does anybody know how I can see the group objects within global groups?
I am working on a program that will print out users and groups within local & global groups in ActiveDirectory.
I can pull Global groups and users out of local groups with the following code, but it cannot see global groups nested in global groups.
strDomain = "WinNT://" & cmbounit.Text & "/"
grp = cmbogroup.Text
Set usergroup1 = GetObject(strDomain & grp)
For Each user In usergroup1.Members
MsgBox user.Name
MsgBox user.Class
Next
Any ideas are greatly appreciated... Thanks.
Retrieving All File Names In A Directory!
Hi, I'm making a program that resembles WinAMP in many ways. I want it to be able to retrieve all MP3 files within a directory! How do I do that?? And also, what control can I use to play MP3 files??
Thank you for any suggestions!
Need Help On Retrieving Table Names From Database
I have a listbox on my form which i need to fill with the table names from an Access database. I have used the following code to do this, but i think there is a reference missing and i don't know which one, because
Code:
Dim daSQL = New SQLDataAdapter(sSQL2, Connect)
and
Code:
Dim Connect As New SQLConnection(sConnectionString)
keep coming up in red and saying that the end of statement was expected ?!?!?!?
Rather Confused, please help - Code Follows:
Code:
While Not rsACD1.EOF
Dim myItem As String
Dim sConnectionString
Dim dtTables As New DataTable
sConnectionString = cnACD1
'Create connection object
Dim Connect As New SQLConnection(sConnectionString)
Dim sSQL2 As String
sSQL2 = "Select Name from dbo.sysobjects "
sSQL2 = sSQL2 & "where OBJECTPROPERTY(id, N'IsView') = 1 "
sSQL2 = sSQL2 & "OR OBJECTPROPERTY(id, N'IsUSERTABLE') = 1 "
Dim daSQL = New SQLDataAdapter(sSQL2, Connect)
daSQL.Fill (dtTables)
lstACD1.DataSource = dtTables
lstACD1.DisplayMember = "Name"
Wend
Retrieving Control Names Of Another Process??
Hello!!!
I am trying to develop a help tool for an already programmed Intranet
application. That is why the "help tool" will run as an independent
process.
What I need to retrieve (from the "help tool") is at least the name
and position of the field selected by the user (the application), so I
am able to search in a database the descritpion of the field the user
selected.
Thanks in advance
Pablo Stapff
Retrieving All Window Names On A Users' Desktop
Hi,
I'm currently trying to write some code which will enable me to get the window 'title bar' text for all open applications on a users desktop. I've tried using EnumDesktopWindows but this returns hidden & system windows as well as Word, Excel etc...
Does anyone know how to return just the application windows that the user can see. (i.e. Just the ones that are visible in the bottom windows bar) ??
Thanks
Sunil.
VBA: Retrieving Sheet Names, And Access Column Headers
Hi,
I am writing a VB6 application that would allow a user to select data from a variety of data sources, including Excel and Access.
For Excel------------------------------------------
I'm trying to retrieve sheet names from a user selected workbook.
I've declared all the objects and set them appropriately, but I'm trying to fill a combo box with the sheet names so they can select it for use.
I'm basically looking for an Excel.Workbook.Worksheets. (Name?) property.
For Access------------------------------------------
I want to be able to then allow them to use selection criteria based on the column headers.
I am looking to retrieve these headers and place them into combo boxes as well.
--------------------------------------------------------
I'm just not clear on how to retrieve these properties in a VB app.
Thanks one and all for your help.
Tojam
Retrieving The Column Names Of A Table - Error Using DESCRIBE?
Hi ppl,
I'm trying to obtain a list of all the column names for a table (using MySQL/VB) - if I use the "DESCRIBE table" or "SHOW COLUMNS FROM table" expressions, I always get "Data provider returned an E_FAIL status", even though I can sit at a MySQL prompt and type that quite happily Any ideas why? Here's the code I'm using:
Code:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With rs
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Source = "SHOW COLUMNS from users"
.LockType = adLockReadOnly
.ActiveConnection = db
.Open
End With
rs.MoveFirst
While Not rs.EOF
fieldlist.AddItem (rs!field)
rs.MoveNext
Wend
rs.Close
Cheers
-rich
Retrieving A Field
I have a combo box that shows the list of a column (name) from a database. What I am hoping to do is when the user selects one of the items in the list, it will retrieve the corresponding item in that row.
Can anyone help me?
Retrieving The First 2 Chars Of A Field
Hi All,
Just wondering how I would go about extracting just the first two chars of a certain field in my database?
Outside of VB I would use
Code:
SELECT LEFT(the_string, 2) from table
But if I use this in VB I get an error "[Informix][Informix ODBC Driver][Informix]Routine (left) can not be resolved. "
Anyone have any ideas as to what i can do?
Retrieving Field By Its Index
I have an ADO recordset.
I can save a Value in a field (named F3 for instance) using:
------------------------------
With Admin.Recordset
!F3 = Value
End With
------------------------------
How can I access field i (i.e., ith field, not knowing its name, something like !Fields(i) = Value) ?
Thanks!
Hervé Chian
Houston, Texas
Retrieving Field Name In VB Via Variable
Trying to retrieve a field out of my recordset via a variable and its not working for me. If anyone could lend a hand it would be appreciated
example of what i'm looking for.
Dim sField as string
set recordset = selectrecordfunction
if not recordset.eof then
variable = recordset.fields(sField)
end if
Retrieving A Database Field To A Variable
Hi All,
I know how to bring data from an access database into a recordset using an SQL statement.
Is it possible to simply read a single value from the database directly into a variable?
Scott
Retrieving From A Memo Field In Access?
Hi!
How do I retrieve data from a memo field in Access? It works OK for insertion, but I get an empty string when performing retrievals. What is the problem?
Thanks in advance!
Field Names
how do we obtain all the field names in a particular table?
waqas
Field Names
Can any one tell me how to get the field names of a table and add them to a table in a different database.
I will use an array and add the fields to it them copy them into the new table, but i can't think of a way to do a for loop for the fields
for i = 0 to Idon'tknow????
next
any help would be good thanks
SQL Field Names
So pretty simple, I want to get all of the field names in the database in the most efficient way... any ideas? Like SQL statement wise?
I guess I could do a select * from table WHERE 0=1 then use a for next for each item in DBRS.FIELDS to get it... any better ways?
I'm using MySQL 4
Best Way To Get Field Names?
Hello!
In a table i have about 2 000 000 records, and I want to get to the tables field names.
Today I run this query: "SELECT * FROM MyTable", and then i get the field names from the recordset i make...
With 2 000 000 records in the table this takes quite a while, som I was wondeing if there is a faster way to get to the field names in a table.
The db is MS Access btw
noccy
Field Names
How can I change the name of a field of a table in an mdb (using ADO preferably) ?
Thanks for any help!
Field Names
hi all. i want to know what code to use to change the name of a field (of say a checkbox) if a condition is met while the program is running.
is it therefore possible to name 5 checkboxes: P1, P2, P3...P5, and then use a variable, (eg : choice) to assign functions to the fields. eg: P(choice).value = True
thank-you for your help.
Field Names Using ADO
Hi,
Having a problem accessing data using the FIELD NAME.
With DAO, I can do the following:
recordset.fields("fieldname")
This gives me access to the data in the field I've supplied.
With ADO, I can't seem to do this, I'm forced to supply an index number with isn't always convenient.
Does ADO support this functionality? If so, how would I access data using a field name rather than an index number?
Any help would be greatly appreciated.
Yazster
ADO Field Names
I have 2 MSACCESS tables that share some field names, s/a NAME, ADDRESS etc... When I performed a join using the Microsoft.Jet.OLEDB.4.0 provider I can access the recordset fields as rs("table_name.field_name") but cannot when I use the MSDASQL provider (ODBC FILE DSN). In that case I have to use the rs.fields(field_number). Is this by design or am I doing something wrong?
VB.NET>CheckedListBox Problem (Retrieving Field Value).. Helpppp!!
Hi,
I'm having problems with retrieving information from the CheckedListBox.
How to retrieve the field value from the checked items, as the checkedlistbox is set to a datasource?The output i get from the code below is "System.Data.DataRowView". Pls help... thanks
[vbtemp]
CheckedListBox1.datasource=dataset.tables("TableName"")
CheckedListBox1.displayMember="DisplayFieldName"
CheckedListBox1.valuemember="ValueFieldName"
Dim intRow As Integer
For intRow = 0 To CheckedListBox1.CheckedItems.Count - 1
CheckedListBox1.CheckedItems.Item(intRow).ToString
Next
[/vbtemp]
Retrieving Data From A Field In Access-RESOLVED
Have a strange problem...cant figure it out...I'm trying to retrieve an autonumber field from a database in Access...the data in the field is: 100001
When I do this:
VB Code:
lblFigure=oRs("Figure")
It only displays 1 and not 100001, if I try to retrieve the field which is next: 100002 it displays only 2...I know its somewhere silly...
Is There A Way To Perform A Function On A Field While Retrieving A Recordset?
OK, this may sound pretty weird, but for performance reasons, I would like to know it.
I have a nice database contains certain problems. I write the problems that the user enters down in the database in RTF format. Now is there a way that I can retrieve this field (Problem) and apply the function RTFToText to it? (this function I 'made' myself)
I want to be able to search the database, but when you would search for example for "f1", it might appaer in RTF codes, so it would select that record, while it shouldn't.
I hope I made my problem kind of clear.
Thank you for ANY response.
Search before you ask - if you don't know where to search, ask before you search
Getting Field Names In A Report
I'm building a report from a query that will generate random field names(names will be days of month like: "31/12 Tue"). I know there's a way to change the Report's column header in execution time I just need to find a way to get the field names while in runtime. Is there a way to get or define the Recordset I'm using on a Report?
Field Names As Variables?
How do I refer to a field name as a Variable or more specifically
Code:
for x = 0 to ubound(sFieldNames())
rstRecordSet!sFieldName(x) = sList(x)
next x
I have polled other dbs for the field names to create a master db, but when I try to put the multiple tables into one then I need to refer to the field names created for the master.
I am trying to compile two separate tables from multiple DBs, in to a master.
Each db has an "Info" table and "Unit" table.
Info is in the standard format but the unit is in a column format.
Essentially each record is equivalent to a column. So the Unit db has 3 columns, DataName, DataCaptured and Notes. Each test run has one database and we need to analyze the data for all the test runs. I have all the preliminary problems solved, but since this needs to work with multiple formats the field Names (columns) need to be dynamic.
Sorry if this is a bit incoherent but it is closing in on 10m here in Thailand and I have been working all day
Using Variables For Field Names
Below is an example of what I'm trying to do.
I'm trying to reference a field via a variable.
strVariableName= "CustomerID"
adoConrol.Recordset.AddNew
adoConrol.Recordset("'" & strVariableName & "'") = "35"
adoConrol.Recordset.Update
Can someone point me in the right direction?
TIA
Avoid These Field Names
Hi all..
Is there a list/site that suggests which field names to avoid when creating a database that will be accessed via SQL statements?
I can create a field with a name of Date in an MSAccess database and it works fine if I stay within MSAccess. However if I'm using VB and SQL Statements I get errors whenever I use the SQL INSERT statement...the syntax error goes away once I rename the field from Date to DateEnd.
I know I can add some unique characters to all my field names to avoid these "reserved words", but is there a list that contains the field names to avoid?
Many Thanks
Brent
Sql Dynamic Field Names
i have a simple query that i am going to save into a stored procedure, my problem is that i was just notified that the field might change during the course of the year
is there a way in sql to define a dynamic varible for a column heading
the column name that i am looking to make dynamic is decile.
<vb>SELECT count(*)
FROM roster
WHERE (roster.apptdate BETWEEN @startdate AND @enddate)
AND roster.meetingcode LIKE @clientcode + '%'
AND decile IN ('7', '8', '9', '10')
</vb>
this works just fine, but wont when the datqa is put under a different column called screener9 for example.
This was just a test example of something i tried, maybe im close, but i doubt that i am.
<vb>
declare @decileFieldName char(10)
set @decileFieldName = 'decile'
SELECT count(*)
FROM roster
WHERE (roster.apptdate BETWEEN @startdate AND @enddate)
AND roster.meetingcode LIKE @clientcode + '%'
AND @decileFieldName IN ('7', '8', '9', '10')
</vb>
This didn't work for me, as i expected it not to, becuase sql just check the variable above it to see if it is equal to 7,8,9,10 .
But i've been looking on the net for examples and havn't found much.
My question is: is this possible, and how can i modify my code above to do it?
TIA,
Tom
Unique Field Names
I have a recordset that retreives two fields with the same name from two different tables:
SELECT T1.Name, T2.Name FROM T1, T2
Code:
Dim adoRs As ADODB.Recordset
Dim fields As ADODB.fields
Dim fld As ADODB.Field
Set fields = adoRs.fields
For Each fld In fields
debug.Print fld.Name
Next
The results are Name, Name
Is there a property so I can get: T1.Name, T2.Name
Without using the SELECT T1.Name As Name1, T2.Name As Name2 ...
to get unique field names ?
Thanks,
Ziko
Populate Cbo With Field Names
Using ADO and a Regular Combo or the DataCombo, How can you automatically list the fields (Field Names) in a Table. i.e: (Biblio.mdb) Table "Titles" and the Field Names are Title, Year Published, ISBN, PubID ect. This is probably a no brainer, but I have been trying to figure this our for a while and I can't find an example or any book ref that address it. Any help would be greatly appreciated.
Field Names Of A Table Using VB
I would appreciate if someboy can post the VB coding for getting the field names of a table using sp_help (table_name). I need only the columns, but I m not getting it with my ado recordset. Plase help
Added [RESOLVED] to thread title and green "resolved" checkmark - Hack
Variables For Field Names
i am trying to use a variable instead of a field name when using access 97, example:
Data1.Recordset.Fields("date").Value = txtdate.Text
Data1.Recordset.Fields("location").Value = txtbox.Text
Data1.Recordset.Fields("strparts").Value = txtpart.Text
i want strparts to be able to change with each users inputs, so the value will be diff everytime... please help
Data1.Recordset.Fields("qty").Value = txtqty.Text
|