Wrox Home  
Search P2P Archive for: Go

  Return to Index  

ado_dotnet thread: asp.net, ado.net & c# question


Message #1 by Duane Douglas <dlists@c...> on Wed, 23 Jan 2002 21:48:43 -0500
--=====================_9172459==_.ALT

Content-Type: text/plain; charset="us-ascii"; format=flowed



hello,



i'm very new to .net, so please bear with me.



i'm getting the following error message:



" Compiler Error Message: CS0246: The type or namespace name 

'SqlConnection' could not be found (are you missing a using directive or an 

assembly reference?)"



the code is below (i indicated the line where the error occurs):



<%@ Page Debug="true" %>

<% Import Namespace="System" %>

<% Import Namespace="System.Data" %>

<% Import Namespace="System.Data.SqlClient" %>

<html>

<head>

<title>Weekly Poll Login</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



</head>

<script language="c#" runat="server">

         private void SubmitBtn_Click(Object sender, EventArgs e) {



                 if (IsPostBack == true) {

                         if (Page.IsValid == true) {



                                 //error occurs on following line:

                                 SqlConnection myConnection = new 

SqlConnection("Data Source=(local);Initial Catalog=WeeklyPoll;Integrated 

Security=false;User ID=sa;Pwd=");

                                 SqlDataAdapter myCommand = new 

SqlDataAdapter("SELECT Count(*)  FROM tblConfiguration WHERE UserName='" + 

txtUserName.text  + "' AND Password = '" + txtUserPass.text + "'" , 

myConnection);



                                 SqlDataReader myReader;

                                 myReader = myCommand.ExecuteReader();

                                 int iRecordCount;

                                 while (myReader.Read) {

                                         iRecordCount = myReader.GetInt32(0);

                                 }



                                 if (iRecordCount == 1) {

                                         Response.Redirect("Controls_Navigat 

Response.Redirect("Controls_NavigationTarget.aspx");

                                 } else {

                                         lblOutput.Text = "Please Enter a 

Valid Login";

                                 }

                         }

                 }

         }

</script>



can someone please help me debug this?



tia






Message #2 by Richard Ainsley <rainsley@p...> on Wed, 23 Jan 2002 19:29:59 -0800
This is a multi-part message in MIME format.



------=_NextPart_000_0132_01C1A444.58DA08A0

Content-Type: text/plain;

	charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable



Looks to me like you forgot to declare SqlConnection myConnection  

before you used it in executable code.  

  ----- Original Message -----

  From: Duane Douglas

  To: ADO.NET

  Sent: Wednesday, January 23, 2002 6:48 PM

  Subject: [ado_dotnet] asp.net, ado.net & c# question





  hello,



  i'm very new to .net, so please bear with me.



  i'm getting the following error message:



  " Compiler Error Message: CS0246: The type or namespace name 

'SqlConnection' could not be found (are you missing a using directive or 

an assembly reference?)"



  the code is below (i indicated the line where the error occurs):



  <%@ Page Debug=3D"true" %>

  <% Import Namespace=3D"System" %>

  <% Import Namespace=3D"System.Data" %>

  <% Import Namespace=3D"System.Data.SqlClient" %>

  <html>

  <head>

  <title>Weekly Poll Login</title>

  <meta http-equiv=3D"Content-Type" content=3D"text/html; 

charset=3Diso-8859-1">



  </head>

  <script language=3D"c#" runat=3D"server">

          private void SubmitBtn_Click(Object sender, EventArgs e) {

         

                  if (IsPostBack =3D=3D true) {

                          if (Page.IsValid =3D=3D true) {

                                 

                                  //error occurs on following line:

                                  SqlConnection myConnection =3D new 

SqlConnection("Data Source=3D(local);Initial 

Catalog=3DWeeklyPoll;Integrated Security=3Dfalse;User ID=3Dsa;Pwd=3D");

                                  SqlDataAdapter myCommand =3D new 

SqlDataAdapter("SELECT Count(*)  FROM tblConfiguration WHERE 

UserName=3D'" + txtUserName.text  + "' AND Password =3D '" + 

txtUserPass.text + "'" , myConnection);

                                 

                                  SqlDataReader myReader;

                                  myReader =3D 

myCommand.ExecuteReader();

                                  int iRecordCount;

                                  while (myReader.Read) {

                                          iRecordCount =3D 

myReader.GetInt32(0);

                                  }

                                 

                                  if (iRecordCount =3D=3D 1) {

                                          

Response.Redirect("Controls_NavigationTarget.aspx");

                                  } else {

                                          lblOutput.Text =3D "Please 

Enter a Valid Login";

                                  }

                          }

                  }

          }

  </script>



  can someone please help me debug this?



  tia ---



$subst('Email.Unsub').






Message #3 by Duane Douglas <dlists@c...> on Wed, 23 Jan 2002 22:30:06 -0500
afaik, i'm declaring and initializing SqlConnection in one statement



At 07:29 PM 1/23/2002 -0800, Richard Ainsley wrote:

>Looks to me like you forgot to declare SqlConnection myConnection  before 

>you used it in executable code.

>>----- Original Message -----

>>From: <mailto:dlists@c...>Duane Douglas

>>To: <mailto:ado_dotnet@p...>ADO.NET

>>Sent: Wednesday, January 23, 2002 6:48 PM

>>Subject: [ado_dotnet] asp.net, ado.net & c# question

>>

>>hello,

>>

>>i'm very new to .net, so please bear with me.

>>

>>i'm getting the following error message:

>>

>>" Compiler Error Message: CS0246: The type or namespace name 

>>'SqlConnection' could not be found (are you missing a using directive or 

>>an assembly reference?)"

>>

>>the code is below (i indicated the line where the error occurs):

>>

>><%@ Page Debug="true" %>

>><% Import Namespace="System" %>

>><% Import Namespace="System.Data" %>

>><% Import Namespace="System.Data.SqlClient" %>

>><html>

>><head>

>><title>Weekly Poll Login</title>

>><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

>>

>></head>

>><script language="c#" runat="server">

>>         private void SubmitBtn_Click(Object sender, EventArgs e) {

>>

>>                 if (IsPostBack == true) {

>>                         if (Page.IsValid == true) {

>>

>>                                 //error occurs on following line:

>>                                 SqlConnection myConnection = new 

>> SqlConnection("Data Source=(local);Initial Catalog=WeeklyPoll;Integrated 

>> Security=false;User ID=sa;Pwd=");

>>                                 SqlDataAdapter myCommand = new 

>> SqlDataAdapter("SELECT Count(*)  FROM tblConfiguration WHERE UserName='" 

>> + txtUserName.text  + "' AND Password = '" + txtUserPass.text + "'" , 

>> myConnection);

>>

>>                                 SqlDataReader myReader;

>>                                 myReader = myCommand.ExecuteReader();

>>                                 int iRecordCount;

>>                                 while (myReader.Read) {

>>                                         iRecordCount = 

>> myReader.GetInt32(0);

>>                                 }

>>

>>                                 if (iRecordCount == 1) {

>> 

>>Response.Redirect("Controls_NavigationTarget.aspx");

>>                                 } else {

>>                                         lblOutput.Text = "Please Enter a 

>> Valid Login";

>>                                 }

>>                         }

>>                 }

>>         }

>></script>

>>

>>can someone please help me debug this?

>>

>>tia ---



>>








Message #4 by Richard Ainsley <rainsley@p...> on Wed, 23 Jan 2002 21:44:14 -0800
I am no expert in C++, but in C and in VB.NET you must declare something

prior to using it in any executable statement.  ou are allowed to combine

the declaration with the NEW operator to create an instance of the item, but

you must always declare it first.  It still appears to me that this is the

case here.  I see no type declaration onl,y the assignment statement.





----- Original Message -----

From: "Duane Douglas" <dlists@c...>

To: "ADO.NET" <ado_dotnet@p...>

Sent: Wednesday, January 23, 2002 7:30 PM

Subject: [ado_dotnet] Re: asp.net, ado.net & c# question





> afaik, i'm declaring and initializing SqlConnection in one statement

>

> At 07:29 PM 1/23/2002 -0800, Richard Ainsley wrote:

> >Looks to me like you forgot to declare SqlConnection myConnection  before

> >you used it in executable code.

> >>----- Original Message -----

> >>From: <mailto:dlists@c...>Duane Douglas

> >>To: <mailto:ado_dotnet@p...>ADO.NET

> >>Sent: Wednesday, January 23, 2002 6:48 PM

> >>Subject: [ado_dotnet] asp.net, ado.net & c# question

> >>

> >>hello,

> >>

> >>i'm very new to .net, so please bear with me.

> >>

> >>i'm getting the following error message:

> >>

> >>" Compiler Error Message: CS0246: The type or namespace name

> >>'SqlConnection' could not be found (are you missing a using directive or

> >>an assembly reference?)"

> >>

> >>the code is below (i indicated the line where the error occurs):

> >>

> >><%@ Page Debug="true" %>

> >><% Import Namespace="System" %>

> >><% Import Namespace="System.Data" %>

> >><% Import Namespace="System.Data.SqlClient" %>

> >><html>

> >><head>

> >><title>Weekly Poll Login</title>

> >><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

> >>

> >></head>

> >><script language="c#" runat="server">

> >>         private void SubmitBtn_Click(Object sender, EventArgs e) {

> >>

> >>                 if (IsPostBack == true) {

> >>                         if (Page.IsValid == true) {

> >>

> >>                                 //error occurs on following line:

> >>                                 SqlConnection myConnection = new

> >> SqlConnection("Data Source=(local);Initial

Catalog=WeeklyPoll;Integrated

> >> Security=false;User ID=sa;Pwd=");

> >>                                 SqlDataAdapter myCommand = new

> >> SqlDataAdapter("SELECT Count(*)  FROM tblConfiguration WHERE

UserName='"

> >> + txtUserName.text  + "' AND Password = '" + txtUserPass.text + "'" ,

> >> myConnection);

> >>

> >>                                 SqlDataReader myReader;

> >>                                 myReader = myCommand.ExecuteReader();

> >>                                 int iRecordCount;

> >>                                 while (myReader.Read) {

> >>                                         iRecordCount 

> >> myReader.GetInt32(0);

> >>                                 }

> >>

> >>                                 if (iRecordCount == 1) {

> >>

> >>Response.Redirect("Controls_NavigationTarget.aspx");

> >>                                 } else {

> >>                                         lblOutput.Text = "Please Enter

a

> >> Valid Login";

> >>                                 }

> >>                         }

> >>                 }

> >>         }

> >></script>

> >>

> >>can someone please help me debug this?

> >>

> >>tia ---



$subst('Email.Unsub').

> >>




$subst('Email.Unsub').

>

>

>




$subst('Email.Unsub').



Message #5 by Beulah Rebekah G <gbrebekah@y...> on Wed, 23 Jan 2002 21:47:23 -0800 (PST)
--0-349457799-1011851243=:10194

Content-Type: text/plain; charset=us-ascii





 The error is , You forgot to put @ symbol before Import.

<%@ Page Debug="true" %>

<%@ Import Namespace="System" %>

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.SqlClient" %>

 

rgds,

Rebekah

  Duane Douglas <dlists@c...> wrote: afaik, i'm declaring and initializing SqlConnection in one statement



At 07:29 PM 1/23/2002 -0800, Richard Ainsley wrote:

>Looks to me like you forgot to declare SqlConnection myConnection before 

>you used it in executable code.

>>----- Original Message -----

>>From: Duane Douglas

>>To: ADO.NET

>>Sent: Wednesday, January 23, 2002 6:48 PM

>>Subject: [ado_dotnet] asp.net, ado.net & c# question

>>

>>hello,

>>

>>i'm very new to .net, so please bear with me.

>>

>>i'm getting the following error message:

>>

>>" Compiler Error Message: CS0246: The type or namespace name 

>>'SqlConnection' could not be found (are you missing a using directive or 

>>an assembly reference?)"

>>

>>the code is below (i indicated the line where the error occurs):

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>

>>         private void SubmitBtn_Click(Object sender, EventArgs e) {

>>

>>                 if (IsPostBack == true) {

>>                         if (Page.IsValid == true) {

>>

>>                                 //error occurs on following line:

>>                                 SqlConnection myConnection = new 

>> SqlConnection("Data Source=(local);Initial Catalog=WeeklyPoll;Integrated 

>> Security=false;User ID=sa;Pwd=");

>>                                 SqlDataAdapter myCommand = new 

>> SqlDataAdapter("SELECT Count(*)  FROM tblConfiguration WHERE UserName='" 

>> + txtUserName.text  + "' AND Password = '" + txtUserPass.text + "'" , 

>> myConnection);

>>

>>                                 SqlDataReader myReader;

>>                                 myReader = myCommand.ExecuteReader();

>>                                 int iRecordCount;

>>                                 while (myReader.Read) {

>>                                         iRecordCount = 

>> myReader.GetInt32(0);

>>                                 }

>>

>>                                 if (iRecordCount == 1) {

>> 

>>Response.Redirect("Controls_NavigationTarget.aspx");

>>                                 } else {

>>                                         lblOutput.Text = "Please Enter a 

>> Valid Login";

>>                                 }

>>                         }

>>                 }

>>         }

>> 

>>

>>can someone please help me debug this?

>>

>>tia ---



>>

















---------------------------------

Do You Yahoo!?

Yahoo! Auctions Great stuff seeking new owners! Bid now!



  Return to Index