chaangeable sql statements

G

Guest

I am going to write an visual studio.net 1.1 application where I would like
to setup dynamic sql statements.
Basically I am going to have a sql server 2000 control table where users
can select via a web page, what columns they want to see with their own
unique (personal) sql server 2000. The control table will be setup to show
what columns
users want to display on their own individual sql server 2000 tables.
Thus basically if a user selects that they want to create a table with
columns #1, #9 and #16 from an option control table, I am wondering if there
a way to string together dynamic sql statements. These dynamic statements
would occur when a table is created and you insert rows into the table.

Thanks!
 
R

Roger Rabbit

Sounds like a security nightmare but given that an Sql statement is just a
string then some simple string concantenation will allow dynamic generation
of table schema.

RR
 
C

Cor Ligthert [MVP]

Wendy,

In addition to Roger, this seems to me nothing more than something as, typed
in this message so watch errors.

\\\\
dim columnames() as string = {"column1", "column2", etc}
dim toselect as string
for each col as integer in WhatIGot
toselect = columnames(col) & ","
next
toselect = toselect.lenght - 1
dim selectstring as string = "select " & toselect & "from mytable"
da.selectcommand = selectstring
///

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top