| | |
Help with SQL
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 101
Reputation:
Solved Threads: 0
ASP.NET Syntax (Toggle Plain Text)
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace WebApplication5 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection( " Server =localhost\\SqlExpress; Database= Dorknozzle; " + "Integrated Secutiry = True" ) ; SqlCommand comm = new SqlCommand( "SELECT EmployeeID, Name FROM Employees", conn); conn.Open(); SqlDataReader reader = comm.ExecuteReader(); reader.Close(); conn.Close(); while (reader.Read()) { employeesLabel.Text += reader["Name"] + "<br/>"; } reader.Close(); conn.Close(); } } }
ASP.NET Syntax (Toggle Plain Text)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication5._Default" %> <%@ Import Namespace = "System.Data.SqlClient" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
how come it does not recgonized the SQL command while I have already imported ?
You need to do it in your code behind file:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WebApplication5
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(
" Server =localhost\\SqlExpress; Database= Dorknozzle; " +
"Integrated Secutiry = True" ) ;
SqlCommand comm = new SqlCommand(
"SELECT EmployeeID, Name FROM Employees", conn);
conn.Open();
SqlDataReader reader = comm.ExecuteReader();
reader.Close();
conn.Close();
while (reader.Read())
{
employeesLabel.Text += reader["Name"] + "<br/>";
}
reader.Close();
conn.Close();
}
}
}•
•
Join Date: Oct 2008
Posts: 101
Reputation:
Solved Threads: 0
•
•
•
•
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(
" Server =se7olutionyg-PC\\SqlExpress; Database= database1.mdf; " +
"Integrated Secutiry = True" ) ;
the program said that this part
SqlConnection conn = new SqlConnection(
" Server =se7olutionyg-PC\\SqlExpress; Database= database1.mdf; " +
"Integrated Secutiry = True" ) ;
the server should be local host or my server name ?
how about the name of database, Do i have to declare the directory to the database or it already included in the project ?
Why the integrated security is not available for my page ?
•
•
•
•
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; namespace WebApplication5 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection( " Server =localhost\\SqlExpress; Database= Dorknozzle; " + "Integrated Secutiry = True" ) ; SqlCommand comm = new SqlCommand( "SELECT EmployeeID, Name FROM Employees", conn); conn.Open(); SqlDataReader reader = comm.ExecuteReader(); reader.Close(); conn.Close(); while (reader.Read()) { employeesLabel.Text += reader["Name"] + "<br/>"; } reader.Close(); conn.Close(); } } }
ASP.NET Syntax (Toggle Plain Text)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication5._Default" %> <%@ Import Namespace = "System.Data.SqlClient" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">
how come it does not recgonized the SQL command while I have already imported ?
I put in bold what you should delete
![]() |
Similar Threads
- Need Microsoft SQL certified professional (Tech / IT Consultant Job Offers)
- SQL Server Developer, Manchester, UK (Software Development Job Offers)
- ASP.NET/SQL Developer/Programmer (Web Development Job Offers)
- Freelance .NET / MS SQL developer (Web Development Job Offers)
- Software Engineer (.NET , SQL) (Software Development Job Offers)
- UPS is Hiring!! PL/SQL & UNIX Technical Specialist (Software Development Job Offers)
- SQL Server DBA - " Hot " (Software Development Job Offers)
- PHP / My SQL Web developer (Web Development Job Offers)
- Sql Dba (Software Development Job Offers)
- SQL Server DBA (Software Development Job Offers)
Other Threads in the ASP.NET Forum
- Previous Thread: Amadeus API Integration
- Next Thread: Master Page Footer
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers






