It involves ASP ADO for connecting to database..I'm using microsoft access table...
I'm a novice to web-development field... :(
I know how to make table choice and display it through VB-Script,but don't have a clear
idea for display of only desirable coloums,PLZ HELP..with it's ASP-code ,I tried a LOT!
ITS MY SEMINAR TOPIC and no one in class knws ASP ADO.

Dani AI

Generated

A concise, safe pattern for (and useful to anyone following 's tip to "post your code"): discover the table's field names with a lightweight query, present those names as checkboxes, validate the posted choices server-side against the discovered list, build a SELECT with bracketed identifiers, then render the resulting recordset. The key points are: never trust raw form input for SQL identifiers, wrap names in square brackets, and validate against the real Fields collection before building the SELECT.

' classic ASP (VBScript) - sketch of the server-side flow
Option Explicit

Dim conn, rs, rs2, allowed, f, sel, arr, sqlCols, col, sql, tableName

Set conn = Server.CreateObject("ADODB.Connection")
' For .mdb (Jet)
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/db/mydb.mdb")
' For .accdb (ACE) use Provider=Microsoft.ACE.OLEDB.12.0

tableName = Request.Form("tablename")
If Len(tableName)=0 Then
  Response.Write "No table selected." : Response.End
End If

' get allowed field names from the DB (SELECT TOP 1 * is quick)
Set rs = conn.Execute("SELECT TOP 1 * FROM [" & Replace(tableName, "]", "]]") & "]")
Set allowed = Server.CreateObject("Scripting.Dictionary")
For Each f In rs.Fields
  allowed.Add LCase(f.Name), True
Next
rs.Close

sel = Request.Form("cols") ' multiple checkboxes named "cols"
If Len(sel)=0 Then
  Response.Write "No columns selected."
Else
  If InStr(sel, ",")>0 Then arr = Split(sel, ",") Else arr = Array(sel)
  sqlCols = ""
  For Each col In arr
    col = Trim(col)
    If col<>"" And allowed.Exists(LCase(col)) Then
      sqlCols = sqlCols & "[" & Replace(col, "]", "]]") & "],"
    End If
  Next
  If Len(sqlCols)>0 Then
    sqlCols = Left(sqlCols, Len(sqlCols)-1)
    sql = "SELECT " & sqlCols & " FROM [" & Replace(tableName, "]", "]]") & "]"
    Set rs2 = conn.Execute(sql)
    ' render header
    Response.Write "<table border='1'><tr>"
    For Each f In rs2.Fields
      Response.Write "<th>" & Server.HTMLEncode(f.Name) & "</th>"
    Next
    Response.Write "</tr>"
    Do While Not rs2.EOF
      Response.Write "<tr>"
      For col = 0 To rs2.Fields.Count-1
        Response.Write "<td>" & Server.HTMLEncode(CStr(rs2.Fields(col).Value & "")) & "</td>"
      Next
      Response.Write "</tr>"
      rs2.MoveNext
    Loop
    Response.Write "</table>"
    rs2.Close
  Else
    Response.Write "No valid columns selected."
  End If
End If

conn.Close
Set rs = Nothing
Set rs2 = Nothing
Set conn = Nothing
Set allowed = Nothing

Notes: replace the Data Source path and choose the correct provider (Jet vs ACE). The IIS user account needs write/modify access to the folder holding the Access file so the Jet engine can create its lock file. For sample connection strings see .

Post your code here so we can advise what to remove/modify.

Hey after long struggle i got everything right :) :) :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.