473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Record Sets

Hi,

Is there a way for me to determing if a column exists in the table? ex. I
have RS("var"), where RS is a recordset. My code is dynamic but some tables
will have "var" while some won't.

Thanks for the help
Shahid
Jul 22 '05 #1
3 1109
"Shahid Juma" wrote ...
Is there a way for me to determing if a column exists in the table? ex. I
have RS("var"), where RS is a recordset. My code is dynamic but some tables will have "var" while some won't.


Hello Shahid,

You didn't mention which database you were using, it might not make any
difference, but with SQL Server you could query the system objects to find
out columns that are within a table, I believe you could also get the data
types and lengths.

This article might give you something you want in a very raw manner:

http://www.4guysfromrolla.com/webtech/112900-1.shtml

You could simply iterate through the rs.fields and check for the existance
of your field...

When you pop the variable after the RS you don't need the quotes either, so
you'd have:

RS(strField)

(I believe)..

Regards

Rob
Jul 22 '05 #2

"Shahid Juma" <sh*****************@hotmail.com> wrote in message
news:uK****************@tk2msftngp13.phx.gbl...
Hi,

Is there a way for me to determing if a column exists in the table? ex. I
have RS("var"), where RS is a recordset. My code is dynamic but some tables will have "var" while some won't.

Thanks for the help
Shahid


For x = 0 to RS.Fields.Count - 1
If RS.Fields(x).Name = strTheName Then
'code to execute if the the column exists
End If

Next
Jul 22 '05 #3
Thanks,

Is there a direct method that could check, ie. exists? Using what you have
below somehow makes my rest of the fields not output.

Shahid

"Hal Rosser" <hm******@bellsouth.net> wrote in message
news:5n*******************@bignews5.bellsouth.net. ..

"Shahid Juma" <sh*****************@hotmail.com> wrote in message
news:uK****************@tk2msftngp13.phx.gbl...
Hi,

Is there a way for me to determing if a column exists in the table? ex. I have RS("var"), where RS is a recordset. My code is dynamic but some

tables
will have "var" while some won't.

Thanks for the help
Shahid


For x = 0 to RS.Fields.Count - 1
If RS.Fields(x).Name = strTheName Then
'code to execute if the the column exists
End If

Next

Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Derek Cooper | last post by:
I hope you can help me. I posted this in the microsoft sql server newsgroup a few days ago and got no response so I thought I'd try here. If I can provide any clarification I'll be glad to do so....
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
1
by: David | last post by:
Hi, I have a continuous form based on a query. Lets say the form displays 6 records. I also have a button against each record which sets a field to Y or N for each record. I am trying to...
0
by: RL | last post by:
Hi, I am trying to implement a few functions in Plpython (in Postgresql 8.0.1). However, I could find the solution in the documentation, so I would appreciate your help. My question is how to...
0
by: Marcelo | last post by:
Hi, I have the following need: I list a table from an access database but cannot interact with each record. At the html page I display all records, one field (field1) from and 3 buttons for each...
2
by: Mark Reed | last post by:
Hi All, I have created a multi-user application at work which is working perfectly apart from a small problem which I believe to more a of a user issue (maybe some will set me straight on that...
19
by: Genalube | last post by:
I have an application that will produce a Word document based on five separate queries this has required that I create a ADODB connection: 'Create connection to current database Dim Conn As...
3
by: Kosmos | last post by:
Hey ya'll...I can't seem to figure out why I'm getting this error message, but it all started when I added the new line of code with the recSet5.AddNew --- when I ran the first line, the logic worked...
1
by: jmarcrum | last post by:
Hello all! i have a “monitor-type” program, where my program recognizes my defined "commands”, and executes the given command, or produces an error message that says “unrecognized command”. After...
19
by: emanning | last post by:
Using Access 2003 and using a form that's mostly bound. I need a way to tell if user-1 is on the record when user-2 tries to open the same record, w/o waiting for the user-1 to save the record...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.