Click here to Skip to main content
15,918,330 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: asp.net Pin
Abhijit Jana25-Oct-10 22:26
professionalAbhijit Jana25-Oct-10 22:26 
AnswerRe: asp.net Pin
Pete O'Hanlon25-Oct-10 22:33
mvePete O'Hanlon25-Oct-10 22:33 
QuestionXML,Xhtml Pin
Any_India25-Oct-10 20:08
Any_India25-Oct-10 20:08 
AnswerRe: XML,Xhtml Pin
thatraja25-Oct-10 20:33
professionalthatraja25-Oct-10 20:33 
AnswerRe: XML,Xhtml Pin
javad200925-Oct-10 21:08
javad200925-Oct-10 21:08 
GeneralRe: XML,Xhtml Pin
Any_India25-Oct-10 21:31
Any_India25-Oct-10 21:31 
GeneralRe: XML,Xhtml Pin
Nithin Sundar27-Oct-10 20:30
Nithin Sundar27-Oct-10 20:30 
QuestionConnectionStringa nd Web.config Pin
future383925-Oct-10 18:52
future383925-Oct-10 18:52 
HI, I write the following code to connect to my database
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Data.ProviderBase;
using System.Configuration;


namespace Hostel.Models.DataAccessLayer
{
    public class PersonDataSet
    {
        DataSet DS = new DataSet();
        SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HostelConnectionString"].ToString());       

        // Create the DataTable "Person_prs" in the Dataset and the its DataAdapter
        SqlDataAdapter PersonDataAdapter = new
        SqlDataAdapter(new SqlCommand("SELECT * FROM Person_prs", Conn));          
    }
}



but after running get this error:
<br />
Error	1	A field initializer cannot reference the non-static field, method, or property 'Hostel.Models.DataAccessLayer.PersonDataSet.Conn'<br />


does any one has any idea?
AnswerRe: ConnectionStringa nd Web.config Pin
thatraja25-Oct-10 20:26
professionalthatraja25-Oct-10 20:26 
QuestionMVC and Dataset Pin
future383925-Oct-10 14:08
future383925-Oct-10 14:08 
AnswerRe: MVC and Dataset Pin
kadaoui el mehdi27-Oct-10 3:33
kadaoui el mehdi27-Oct-10 3:33 
QuestionWebpage template Pin
yakshasa25-Oct-10 11:56
yakshasa25-Oct-10 11:56 
QuestionLinq to SQL Pin
Satish_S25-Oct-10 2:39
Satish_S25-Oct-10 2:39 
AnswerRe: Linq to SQL Pin
dan!sh 25-Oct-10 11:03
professional dan!sh 25-Oct-10 11:03 
GeneralRe: Linq to SQL Pin
Satish_S25-Oct-10 18:04
Satish_S25-Oct-10 18:04 
GeneralRe: Linq to SQL Pin
dan!sh 25-Oct-10 19:51
professional dan!sh 25-Oct-10 19:51 
GeneralRe: Linq to SQL Pin
Satish_S25-Oct-10 20:41
Satish_S25-Oct-10 20:41 
QuestionQuestions about ASPNETDB.MDF Pin
ibmkahm24-Oct-10 22:14
ibmkahm24-Oct-10 22:14 
AnswerRe: Questions about ASPNETDB.MDF Pin
kadaoui el mehdi27-Oct-10 3:41
kadaoui el mehdi27-Oct-10 3:41 
QuestionCan't figure out how to covnert this XML to XSL for a gridview Pin
Albert8324-Oct-10 19:01
Albert8324-Oct-10 19:01 
QuestionObjectDisposedException when using Response.Filter Pin
95ulisse24-Oct-10 5:06
95ulisse24-Oct-10 5:06 
QuestionWeb Service Complex Type returning Pin
Dirso23-Oct-10 13:06
Dirso23-Oct-10 13:06 
AnswerRe: Web Service Complex Type returning [modified] Pin
Karthik. A23-Oct-10 15:37
Karthik. A23-Oct-10 15:37 
GeneralRe: Web Service Complex Type returning Pin
Dirso26-Oct-10 9:16
Dirso26-Oct-10 9:16 
AnswerRe: Web Service Complex Type returning Pin
Keith Barrow23-Oct-10 21:56
professionalKeith Barrow23-Oct-10 21:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.