Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > Classic ASP

Reply
 
LinkBack Thread Tools
Old December 21st, 2008, 01:34 AM   #1
New Member
 

Join Date: Dec 2008
Location: Egypt
Age: 25
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 AliHabib is on a distinguished road
Question connect to sql server 2005 problem

Hi every one,
this is my first ask and task in asp classic I wrote this code to connect to sql server 2005 to retrieve data but it not work any help please , also how to display the result of the page
Code:
<html>
 <head>
  
 </head>
 <body>
  <%
   dim conn
   strconn ="Provider=SQLNCLI.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MailSystem;Data Source=."
   Set cnt =Server.CreateObject("ADODB.Connection")
   cnt.ConnectionString= strconn
   cnt.Open
  %>
  <form method="Post">
   Enter Search Name <Input type="text" name="First"/> 
   <select name="Filter">
    <option>And</option>
    <option>Or</option>
   </select>
   <Input type="text" name="Second"/>
   <Input type="Submit" value="Search" name="Search"/>
  </form>
  <% if  Request.Form("Second")<>"" then
    sql="exec selectMesseges1'" & First & "','" & Filter & "','" & Second & "'"
   else
    sql="select *  from MessegesIDTable where subject like '" & First & "'+'%'"
   
   set rs=Server.CreateObject("ADODB.Recordset")
   rs.Open sql,cnt
   
   
  %>
 <table width="100%" cellspacing="0" cellpadding="2" border="1">
   <tr>
     <th>ID</th>
     <th>MailFrom</th>
     <th>ToID</th>
  <th>subject</th>
     <th>messege</th>
     <th>AttachedFile</th>
  <th>date</th>
     <th>read</th>
     <th>typeID</th>
   </tr>
   <%
 do until rs.EOF
     response.write("<tr>")
     response.write("<td>" & rs.fields("ID") & "</td>")
     response.write("<td>" & rs.fields("MailFrom") & "</td>")
     response.write("<td>" & rs.fields("ToID") & "</td>")
     response.write("<td>" & rs.fields("subject") & "</td>")
     response.write("<td>" & rs.fields("messege") & "</td>")
     response.write("<td>" & rs.fields("AttachedFile") & "</td>")
     response.write("<td>" & rs.fields("date") & "</td>")
     response.write("<td>" & rs.fields("read") & "</td>")
     response.write("<td>" & rs.fields("typeID") & "</td>")
     response.write("</tr>")
     rs.MoveNext
 loop
 rs.close
 conn.Close
 set rs=Nothing
 set conn=Nothing%>
 </table>
 <%  end if %>
 </body>
</html>

Last edited by AliHabib; December 21st, 2008 at 01:37 AM..
AliHabib is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't connect to my server... What do I do? JustinStudios Web Hosting and Domains 11 January 23rd, 2008 03:44 AM
connect two sql server via lan ? navvabi Databases 1 November 13th, 2007 04:30 PM
Querying Microsoft SQL server 2005 alexgeek Classic ASP 14 September 29th, 2007 09:28 PM
Trouble connecting to Sql Server 2005 Management Studio Express? annawilsonz Databases 0 September 14th, 2007 02:30 AM
Multi user support for SQL Server Express 2005 ish Databases 1 May 9th, 2007 12:51 PM


Search Engine Optimization by vBSEO 3.2.0 RC8