Getting column names from DB

  • When i get data from my SQL -DB, i use diffent values. when i seearch by specific recordvalues, i wish getting the name of the column back too for both the value and these which are joined. How can i do this?

    i search by:

    Set oRs = Server.CreateObject("ADODB.Recordset") oRs.LockType = adLockReadOnly 

    if isNumeric(CStr(GNavn)) then GNavn = GNav and Tabel = Tabel1 else GNavn = GNavn

    strSQL: SELECT...FROM... " WHERE (" & Tabel & " like '" & GNavn & "') or " &_ "" & Tabel1 & "=" & GNav

    and reports by: Do While Not (oRs.EOF or oRs.BOF) AND NOT Crit_Error

    RStr = RStr & CStr(oRs("Vkt_nr").Value) & ", " &_ CStr(oRs("navn").Value)& Endline & Endline.

    This navn and Vkt_nr i wish to chance to automated values from the queryresult. Any suggestions?

  • This was removed by the editor as SPAM

  • Hi eric,

    if you can explain me exactly what information you want from the database, i can help you out with sql but can't with VB

    Thanks,

  • I wish, when i get the result of an SQL-QUery, to find the value of the names of the matching columnnames and insert these in the variable for output. This is instead of having 20 lines to sort among when the result of the query is send or written. For the moment i wish to have them writtten into an browserwindov for test casulties, and therefore uses the lines form before. Right now i test by using the fixed names VKt_nr  and navn.

    I have found out i can use table.head to find the matching tables, but i need to get one more step. I tried by using inner loops

    The Query :

    strSQL = " SELECT * " &_ " FROM dbo.Gruppe RIGHT OUTER JOIN " &_ " dbo.Undergruppe RIGHT OUTER JOIN " &_ " dbo.Ops_undervkt RIGHT OUTER JOIN " &_ " dbo.Ejer RIGHT OUTER JOIN " &_ " dbo.Hovedtabel ON dbo.Ejer.id = dbo.Hovedtabel.ejer LEFT OUTER JOIN " &_ " dbo.Ibrug ON dbo.Hovedtabel.ibrug = dbo.Ibrug.id LEFT OUTER Join " &_ " dbo.Leverandor ON dbo.Hovedtabel.leverandor = dbo.Leverandor.Id LEFT OUTER JOIN " &_ " dbo.Kunde ON dbo.Hovedtabel.kunde = dbo.Kunde.k_id ON dbo.Ops_undervkt.id_ops_under = dbo.Hovedtabel.ops_undervkt LEFT OUTER JOIN " &_ " dbo.Anvendelse ON dbo.Hovedtabel.anvendelse = dbo.Anvendelse.id_anvendelse LEFT OUTER JOIN " &_ " dbo.Ops_overvkt ON dbo.Hovedtabel.ops_overvkt = dbo.Ops_overvkt.id_ops_over ON " &_ " dbo.Undergruppe.id_undergruppe = dbo.Hovedtabel.undergruppe ON dbo.Gruppe.id_Gruppe = dbo.Hovedtabel.gruppe " &_ " WHERE (" & Tabel & " like '" & GNavn & "') or " &_ "" & Tabel1 & "= " & GNav

    where Tabel, Gnavn, Tabel1 & GNav are variables, Tabel1 & GNav for use when numeric searchvalue.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply