Jump to content
crazyswede

build a command

Recommended Posts

var ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + AbsolutePathToAccessFile + ";";

var ConnectionObject = Server.CreateObject("ADODB.Connection");

ConnectionObject.Open( ConnectionString );

var sql = "SELECT * FROM santa1 ";

var rs = Server.CreateObject("ADODB.RecordSet");

rs.Open (sql, ConnectionObject);

fff = GetFieldToRead( databasename );

---------------------------------

My program reads an *.mdb file----> SantaName = rs("man1").Value

But it changes every month - February= rs("man2").Value,  march= rs("man3").Value, and so forth. I could and have used if-statements, but I want to learn how to build or customize that command. Would it be like you build a string? - = "rs(/""+ fff +"/").Value)", where fff signifies man1 or man2 or man3, etc. Just point me in the right direction and I'll study it.

Share this post


Link to post
Share on other sites

It's possible to build a string of code and then use eval to execute it, but that's generally considered to be bad practice especially if any user-entered data is part of that command.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×