Click here to Skip to main content
15,921,905 members
Home / Discussions / Database
   

Database

 
GeneralDataSet query Pin
Shaun Wilde11-Feb-03 23:46
Shaun Wilde11-Feb-03 23:46 
GeneralRe: DataSet query Pin
Mazdak12-Feb-03 1:10
Mazdak12-Feb-03 1:10 
GeneralRe: DataSet query Pin
Shaun Wilde12-Feb-03 1:26
Shaun Wilde12-Feb-03 1:26 
GeneralRe: DataSet query Pin
Bruce Duncan12-Feb-03 7:04
Bruce Duncan12-Feb-03 7:04 
GeneralRe: DataSet query Pin
Shaun Wilde12-Feb-03 22:12
Shaun Wilde12-Feb-03 22:12 
GeneralRe: DataSet query Pin
Bruce Duncan13-Feb-03 7:12
Bruce Duncan13-Feb-03 7:12 
GeneralColumn number in SELECT Pin
Mazdak11-Feb-03 23:08
Mazdak11-Feb-03 23:08 
GeneralRe: Column number in SELECT Pin
andyharman11-Feb-03 23:31
professionalandyharman11-Feb-03 23:31 
Hi Mazdak

Mazdak wrote:
How can I pass,number of column instead of its name in my SLELECT statement.Like this:

Select * from mytable WHERE COLUMNNUMBER5='something'


I'm not aware of any database engines that allow you to directly do what you have asked for. However you should be able to persuade .Net to help you out with something like the following:
//Construct datatable with schema of mytable ...<br />
OleDbCommand comm = new OleDbCommand("mytable", conn) ;<br />
comm.CommandType = CommandType.TableDirect ;<br />
OleDbDataReader reader = comm.ExecuteReader(CommandBehaviour.SchemaOnly) ;<br />
DataTable dt = reader.GetSchemaTable() ;<br />
reader.Close() ;


The dt datatable should now contain details of each column in the table. Use the following to show the details on a grid:
this.dataGrid1.SetDataBinding(dt) ;

You should now be able to fabricate a new SQL Select statement by reading the appropriate column details (the ColumnName and DataType) from the datatable.

Hope this helps.
Andy
GeneralRe: Column number in SELECT Pin
Mazdak12-Feb-03 1:05
Mazdak12-Feb-03 1:05 
GeneralUsing Group By Properly Pin
perlmunger11-Feb-03 18:55
perlmunger11-Feb-03 18:55 
GeneralRe: Using Group By Properly Pin
Richard Deeming11-Feb-03 23:44
mveRichard Deeming11-Feb-03 23:44 
GeneralRe: Using Group By Properly Pin
andyharman11-Feb-03 23:45
professionalandyharman11-Feb-03 23:45 
GeneralRe: Using Group By Properly Pin
perlmunger12-Feb-03 2:54
perlmunger12-Feb-03 2:54 
GeneralRe: Using Group By Properly Pin
andyharman12-Feb-03 4:27
professionalandyharman12-Feb-03 4:27 
GeneralRe: Using Group By Properly Pin
perlmunger12-Feb-03 6:03
perlmunger12-Feb-03 6:03 
GeneralRe: Using Group By Properly Pin
andyharman12-Feb-03 23:51
professionalandyharman12-Feb-03 23:51 
GeneralRe: Using Group By Properly Pin
perlmunger13-Feb-03 5:18
perlmunger13-Feb-03 5:18 
GeneralRe: Using Group By Properly Pin
andyharman13-Feb-03 6:18
professionalandyharman13-Feb-03 6:18 
Generalexception when call (recordset.open "select * from db where ID='aa'") Pin
rxl11-Feb-03 5:57
rxl11-Feb-03 5:57 
GeneralRemote DataSet Pin
Amir Harel10-Feb-03 22:13
Amir Harel10-Feb-03 22:13 
Generaltrouble concatenating a SQL string that returns @token on-the-fly. Pin
devvvy10-Feb-03 21:39
devvvy10-Feb-03 21:39 
QuestionHow connect ADOX to Excel? Pin
Anonymous10-Feb-03 18:14
Anonymous10-Feb-03 18:14 
AnswerRe: How connect ADOX to Excel? Pin
andyharman12-Feb-03 4:45
professionalandyharman12-Feb-03 4:45 
QuestionCan anyone give me an example of these SQL statements?? Pin
IrishSonic10-Feb-03 12:01
IrishSonic10-Feb-03 12:01 
AnswerRe: Can anyone give me an example of these SQL statements?? Pin
Alexander Kojevnikov11-Feb-03 6:42
Alexander Kojevnikov11-Feb-03 6:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.