PC Review


Reply
Thread Tools Rate Thread

ASP.NET connection file problem

 
 
=?Utf-8?B?YXNhZA==?=
Guest
Posts: n/a
 
      27th Jan 2005
Hello friends,
I have some problem in my ASP.NET connection
'Connection file code
<%
dim connstr
connstr=("Provider=Microsoft.Jet.OLEDB.4.0;data
source="&server.mappath("database/it.mdb")&"")
%>
follwoing error message occur when i execute the page
Compiler Error Message: BC30451: Name 'connstr' is not declared.

'Below is the file where i am using it

<!-- #include file="connection.aspx"-->
<script language="VB" runat="server">
Public Sub searchsh()
Response.Write ("<table align=center width=100% cellspacing=4 cellpadding=0
border=0><tr>")
Response.Write ("<td width=30% align=middle valign=top bgcolor=SaddleBrown>")
Response.Write ("<table align=center width=100% cellspacing=2 cellpadding=0
border=0><tr>")
Response.Write ("<td width=100% align=middle><font size=2 color=Azure
face=Arial, Helvetica, sans-serif>")
Response.Write ("<b>NAME</b></font></td></tr></table></td>")
Response.Write ("<td width=30% align=middle valign=top bgcolor=SaddleBrown>")
Response.Write ("<table align=center width=100% cellspacing=2 cellpadding=0
border=0><tr>")
Response.Write ("<td width=100% align=middle><font size=2 color=Azure
face=Arial, Helvetica, sans-serif>")
Response.Write ("<b>ADDRESS</b></font></td></tr></table></td>")

Response.Write ("<td width=15% align=middle valign=top bgcolor=SaddleBrown>")
Response.Write ("<table align=center width=100% cellspacing=2 cellpadding=0
border=0>")
Response.Write ("<tr><td width=100% align=middle>")
Response.Write ("<font size=2 color=Azure face=Arial, Helvetica,
sans-serif><b>HELLO</b></font></td>")
Response.Write ("</tr></table></td>")
Response.Write ("<td width=15% align=middle valign=top bgcolor=SaddleBrown>")
Response.Write ("<table align=center width=100% cellspacing=2 cellpadding=0
border=0>")
Response.Write ("<td width=100% align=middle><font size=2 color=Azure
face=Arial, Helvetica, sans-serif><b>Email</b></font></td>")
Response.Write ("</table></td></tr>")

Dim sqlq="SELECT * from softhouse where cityID Like'"&Request.Form("city")&"'"
Dim objdatareader as new OLEDBDataReader
Dim cmdobj as new OLEDBCommand(sqlq,objconn)
'objDataReader=cmdobj.Executereader()
</script>


<%if Request.Form("searchchoice")=1 then
searchsh
end if
%>


 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      27th Jan 2005
Hard to tell where the error is. It is obvious that there is something wrong
with connstr.
Try with
Dim connstr="Provider=Microsoft.Jet.OLEDB.4.0;data
source="&server.mappath("database/it.mdb")&""


"asad" <(E-Mail Removed)> wrote in message
news:9E008B2A-AA0D-4C51-9285-(E-Mail Removed)...
> Hello friends,
> I have some problem in my ASP.NET connection
> 'Connection file code
> <%
> dim connstr
> connstr=("Provider=Microsoft.Jet.OLEDB.4.0;data
> source="&server.mappath("database/it.mdb")&"")
> %>
> follwoing error message occur when i execute the page
> Compiler Error Message: BC30451: Name 'connstr' is not declared.



 
Reply With Quote
 
Ranjan
Guest
Posts: n/a
 
      27th Jan 2005
Try to store this string in a web.config file, and use it from there, using
ConfigSettings.AppSettings.

Please note that you have declared a variable within tags of the
Connection.aspx file, which becomes a private variable, hence you cannot
use it. In any case though, this is a bad practice, and yuou should go for
the web.config file.

Ranjan
http://dotnetjunkies.com/weblog/dotnut
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Workgroup file connection problem!!! Lilian Microsoft Access Security 15 3rd Apr 2009 05:39 PM
DBASE file connection problem :( Aleyna[] Microsoft C# .NET 6 1st Feb 2008 05:44 PM
Network connection/file sharing problem. =?Utf-8?B?RWluZXk=?= Windows XP Networking 5 5th Aug 2004 11:15 AM
Problem accessing a file thru a VPN connection. J Ryan Microsoft Access Security 2 26th Jan 2004 04:28 AM
serial connection file sharing problem Dave Windows XP Networking 0 19th Jul 2003 07:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:29 AM.