Hello and Thank you I need to Script a db “Query Results†Web Page. My scripting skill is basic. I am working with: Classic ASP / VBScript / MS SQL / 3rd Party Shared Sever I already have : A Two Field Query Form, A db Connection String in a “include†file and A Query String I need help with the ASP script & syntax to: Display Results on Web Page, Many Thanks
What exactly do you want to do? Do you want to just display the values that you fetch using the query strings? If yes then why you want the db functionality. Or do you want to just add that two fields into the db or want to search the db using that two fields and display the result(or selected row)? please elaborate.
Thank you for responding Here is what I want to do : Search the db using the two fields and display the results.
Try with the below code. You will need to modify this code according to your table schema and page elements. <% DIM strconnectiostring, objConn, objRecordset Set objConn = Server.CreateObject("ADODB.Connection") strDataSourceName="Provider=sqloledb;Data Source=YOURDATABASESERVER,1433;Network Library=DBMSSOCN;Initial Catalog=YOURDATABASENAME;User ID=DATABASEUSERNAME;Password=DATABASEPASSWORD;" objConn.connectionstring = strconnectiostring Set objRecordset = Server.CreateObject("ADODB.Recordset") objConn.Open rs.open "select * from TABLENAME where field1 = querystring1 and field2=querystring2" ' suppose there are 5 fields Response.write(str(rs(0))) Response.write(str(rs(1))) Response.write(str(rs(2))) Response.write(str(rs(3))) Response.write(str(rs(4))) %> Code (markup):
= = I modified the code and ran a successful test. <% Dim MM_sql_conn_info_STRING dim conn_uid, conn_pwd,conn_machine,conn_dbname conn_uid = "userid" conn_pwd = "password" conn_machine = "000.000.000.000" conn_dbname = "dbname" MM_sql_conn_info_STRING = "Provider=SQLOLEDB.1;Persist Security Info=False;uid=" & conn_uid & ";pwd=" & conn_pwd & ";Initial Catalog=" & conn_dbname & ";Data Source=" & conn_machine & ";" set conn = CreateObject("ADODB.Connection") conn.open MM_sql_conn_info_STRING ' Test connection '--------------------------------------------- Set oRs = conn.Execute("SELECT * FROM TABLENAME;") If Not oRs.EOF Then Do While Not oRs.EOF Response.Write oRs(0) & "<br>" oRs.MoveNext Loop End If %> Code (markup): I now need some guidance to structure; QUERY, FORM, RESULTS Thanks for your help