daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <%@ Page Language="C#" %>
  2.  
  3. <%@ Import Namespace="System.Data.SqlClient" %>
  4.  
  5. <%  
  6.     SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\Owner\My Documents\Visual Studio 2008\WebSites\WebSite1\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
  7.     connection.Open();
  8.    
  9.     String name = Request.Params["name"];
  10.    
  11.     if (name == null) {
  12.         name = "steve";
  13.     }
  14.    
  15.     SqlCommand command = new SqlCommand("INSERT INTO test (name) VALUES ('" + name + "')", connection);
  16.     command.ExecuteNonQuery();
  17.    
  18.     command = new SqlCommand("SELECT * FROM test", connection);
  19.     SqlDataReader reader = command.ExecuteReader();
  20.    
  21.     while (reader.Read()) {
  22.         Response.Write("<p>" + reader["name"] + "</p>");
  23.     }
  24.    
  25.     reader.Close();
  26.     connection.Close();
  27. %>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top