CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.personal_site_starter_kit Tags:
Item Type: NewsGroup Date Entered: 8/30/2006 6:30:53 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 19 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
rhhanson63
Asp.Net User
Database Connection Question8/30/2006 6:30:53 PM

0/0

I am currently attempting to integrate a Hit Counter to the site that has the following ascx file.  I am unable to get a DB connection no matter how I modify the objConnection portion.  The site is using the standard "Personal" connection on the development PC and the modified connection string for Go Daddy, both working well without the Hit Counter portion.


 Public Display As String  ' {TEXT|images|none}

 Sub Page_Load(Source As Object, E As EventArgs)
  Dim strFileName   As String
  Dim objConnection As SqlConnection
  Dim objCommand    As SqlCommand
  Dim strSQLQuery   As String
  Dim intCount      As Integer

  ' Get name of the file using the counter to use as db key.
  ' --------------------------------------------------------
  strFileName = Request.ServerVariables("SCRIPT_NAME")

  ' Set up our database connection.
  ' -------------------------------
  objConnection = New SqlConnection("Data Source=10.2.1.214;" _
   & "Initial Catalog=samples;User Id=samples;Password=password;" _
   & "Connect Timeout=15;Network Library=dbmssocn;")

  ' Get current hit count for the page using the counter.
  ' -----------------------------------------------------
  ' Build SQL query that retrieves the current count.
  strSQLQuery = "SELECT hit_count FROM hit_count WHERE page_name='" & strFileName & "';"

  ' Create new command object passing it our SQL query
  ' and telling it which connection to use.
  objCommand = New SqlCommand(strSQLQuery, objConnection)

  ' Open conn. Execute query. Leave conn open for update.
  objConnection.Open()
  intCount = objCommand.ExecuteScalar()

  ' Increment count.
  ' ----------------
  intCount = intCount + 1

  ' Write new count back to the database.
  ' -------------------------------------
  ' If intCount = 1 then we retrieved a zero which should mean
  ' that there's no record in the DB for this filename so we
  ' need to insert a new record.  Build SQL accordingly.
  ' If you ever need to reset a counter... start it at 1!
  If intCount = 1 Then
   strSQLQuery = "INSERT INTO hit_count " _
    & "(page_name, hit_count) " _
    & "VALUES ('" & strFileName & "', 1)"
  Else
   strSQLQuery = "UPDATE hit_count " _
    & "SET hit_count=" & intCount & " " _
    & "WHERE page_name='" & strFileName & "';"
  End If

  ' Set up our command.
  objCommand = New SqlCommand(strSQLQuery, objConnection)
  
  ' Execute the command and close the connection.
  objCommand.ExecuteNonQuery()
  objConnection.Close()

  ' Display count.
  ' --------------
  Select Case LCase(Display)
   Case "none"
   Case "images"
    litCounter.Text = GetCountImage(intCount)
   Case Else '"text"
    litCounter.Text = intCount
  End Select
 End Sub

 Function GetCountImage(strCount As String) As String
  Dim I       As Integer
  Dim strTemp As String

  strTemp = ""

  ' Build a string that will display our image files.
  ' You can easily replace the files modify the string
  ' or do whatever else you want.
  For I = 1 to Len(strCount)
   strTemp = strTemp & "<img src=""images/digit_"
   strTemp = strTemp & Mid(strCount, I, 1)
   strTemp = strTemp & ".gif"" alt="""
   strTemp = strTemp & Mid(strCount, I, 1)
   strTemp = strTemp & """ width=""20"" height=""27"" />"
  Next I

  GetCountImage = strTemp
 End Function
</script>
<asp:Literal id="litCounter" runat="server" />

I am having difficulty getting this changed to work with the "Personal" DB.

I need this to work via the web.config file so it works locally on the development PC and also when hosted on Go Daddy.  I have the site minus the Hit Counter working on both at this time.

Anyone have any ideas? 

 


Robert H. Hanson
Javier Luna
Asp.Net User
Re: Database Connection Question8/31/2006 4:47:20 PM

0/0

Hi Hanson,

This isn't clear. Can you be more explicit?

Good Coding!

Javier Luna
http://guydotnetxmlwebservices.blogspot.com/

 


from Villa El Salvador for world!
rhhanson63
Asp.Net User
Re: Database Connection Question8/31/2006 8:35:38 PM

0/0

Hey,

 I wish I could take credit for the coding, but it isn't mine.  I downloaded it.

The code is for a hit counter.  the issue arises in:

 Set up our database connection.
  ' -------------------------------
  objConnection = New SqlConnection("Data Source=10.2.1.214;" _
   & "Initial Catalog=samples;User Id=samples;Password=password;" _
   & "Connect Timeout=15;Network Library=dbmssocn;")

I run the development on my laptop and the production on Go Daddy.  I am trying to find a way to change the connection information above to use the web.config connection settings so it works both on my development box (SQL Express) and on Go Daddy (SQL 2000).  When I compile the site will not run as it can not establish a connection as it is coded.

My production connection settings look like this:

<connectionStrings>

<add name="Personal" connectionString="Data Source=whsql-v04.prod.mesa1.secureserver.net;Initial Catalog=DB_#####;User ID=#####;Password='#####';Trusted_Connection=False" providerName="System.Data.SqlClient"/>

<remove name="LocalSqlServer"/>

<add name="LocalSqlServer" connectionString="Data Source=whsql-v04.prod.mesa1.secureserver.net;Initial Catalog=DB_#####;User ID=#####;Password='#####';Trusted_Connection=False" providerName="System.Data.SqlClient"/>

</connectionStrings>

My production connection settings look like this:

<connectionStrings>

<add name="Personal" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Personal.mdf" providerName="System.Data.SqlClient" />

<remove name="LocalSqlServer"/>

<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" />

</connectionStrings>

Bob


Robert H. Hanson
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
FrontPage 2003: The Missing Manual Authors: Jessica Mantaro, Pages: 411, Published: 2005
FrontPage 2003 All-in-One Desk Reference For Dummies: all-in-one desk reference Authors: John Paul Mueller, Pages: 792, Published: 2004
Learning PHP and MySQL: A Step-by-Step Guide to Creating Dynamic, Database-Driven Web Sites Authors: Michele E. Davis, Jon Phillips, Pages: 411, Published: 2007
How to Do Everything with Microsoft Office FrontPage 2003 Authors: David Plotkin, Pages: 464, Published: 2003
How to Do Everything with FrontPage 2002: How to Do Everything With.. ... Authors: David Plotkin, Pages: 633, Published: 2001
JDBC Recipes: A Problem-solution Approach Authors: Mahmoud Parsian, Pages: 635, Published: 2005
Java Database Best Practices Authors: George Reese, Pages: 267, Published: 2003
Philip and Alex's Guide to Web Publishing Authors: Philip Greenspun, Pages: 577, Published: 1999
Java RMI: Designing & Building Distributed Applications Authors: William Grosso, Pages: 545, Published: 2002
Visual Basic.Net by Example Authors: Gabriel Oancea, Robert P. Donald, Pages: 976, Published: 2002

Web:
Hottest "database-connection" Questions - Stack Overflow questions tagged. database-connection. sorted by hotness. Questions with the most recent interest and activity will appear first. ...
Multiple Database Connection Question | CodeIgniter Forums Multiple Database Connection Question ... ok, i need to connect to multiple databases… i have read the user guide but i have a question about it… ...
Using Moodle: Database Connection - beginner`s questions Database Connection - beginner`s questions. by Márcio Vilaça - Friday, 2 May 2008, 09:39 PM. I thank you for your help. PHP variables/MySql database: ...
[Mapnik-users] Mapnik database connection Questions [Mapnik-users] Mapnik database connection Questions. Artem Pavlenko artem at mapnik.org Thu Jul 19 12:37:30 CEST 2007. Previous message: [Mapnik-users] ...
Database connection questions | Business Objects Diamond Technical ... C F, Posted: August 14th, 2006Database connection questions. Posts: 47 Member Since: Aug 09, 2006. Default User Picture ...
WordPress › Support » Error establishing a database connection (no ... Blog worked perfectly yesterday logged on this morning and I get ONLY the following message:. Error establishing a database connection. No questions nothing ...
play framework question #47651: “sqlite database connection” Oct 10, 2008 ... sqlite database connection. Hi, I'm trying to connect to a sqlite database using the SQLiteJDBC driver found here: ...
How to establish the database connection using QTP? Code Style: JDBC frequently asked questions (FAQ). Developing a database connection pool is a relatively advanced project. You should consider using an ...
database connection failing from linux - UNIX for Dummies ... Connection problem with gui java program to postgreaql database using unix, uci, UNIX for Dummies Questions & Answers ...
Jackrabbit database connection question Jackrabbit database connection question. Khanapurkar, Mona A. Wed, 03 Oct 2007 18:33:31 -0700. Hello, I would like to know how jackrabbit connects to ...

Videos:
Guide to broadband.co.uk Welcome to broadband.co.uk In this guide we'll show you the key features of the site lets begin by checking the broadband availability for a post...
How to make a WoW private server for 2.4.3 CLICK 'MORE INFO' ---------------------------------------- Download: http://www.mediafire.com/?pce00wzfgmt .NET Framework 3.5: http://www.microsof...
How to make a WoW private server for 2.4.2 CLICK 'MORE INFO' ---------------------------------------- New vid for 2.4.3! http://www.youtube.com/watch?v=ajJ8b7gUWtk Download: http://www.medi...
How To: Create a WoW private server for 2.4.3 by TNG CLICK 'MORE INFO' ---------------------------------------- Download: http://www.mediafire.com/?pce00wzfgmt .NET Framework 3.5: http://www.microsoft....
An Introduction to SQLite Google TechTalks May 31, 2006 Richard Hipp ABSTRACT SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQ...
Movie Downloads & Over 10 Million Mp3 Files To Download http://box33.movies01.hop.clickbank.net/ Click here To Visit Site. I'm new to downloading, how easy is it to get started? You can be downloading wi...
Objects: they just work Google London Test Automation Conference (LTAC) Google Tech Talks September 8th, 2006 Presenter: Bob Binder
How to make a WoW private server for 2.3.3 READ THIS!! click more --------------------------------- NEW VIDEO!!! http://www.youtube.com/watch?v=hgO5SPxXEYY Just follow the vid (the vendors ...
How to make a private server 2.3.3 NOTE: Im not the producer of this repack it's Johved http://www.prizerebel.com/index.php?r=202593 and earn points by completing offers goes fast 6...
Mitt i Schack - 129 Krzymowska - Chess News - Sverige - Sweden This episode contains: * Ice chess London vs. Moscow * Susan Polgar's journey to Budapest * Wijk aan Zee has started * Peter Leko won the ACP World r...




Search This Site:










"localhost" problem

possible bug encountered involving skinning solpartmenu

problem in accessing child page controls

help with master pages

free weather module

contentplaceholder help

password problem??????

object reference not set to an instance of an object

dotnetnuke register link problem

error when installing module definitions - dnn 4.0

knowing if a component is at design time or run time

issue deleting module that is giving errors

*urgent* - access is denied problem with asp.net 1.1 application

problem with tracing in vs 2005

how do i trap editor zone close verb click?

free resource directory v1.1 final available

horizontal menu using sitemap and menu controls

treeview with anchor tags

convert dnn v 2.x module to dnn v3.x?

asp.net 2.0 treeview node custom javascript?

local host username & password

recovering admin logins after upgrade

singout problem.

javascript errors using asp.net menus

file manager questions.. (3.0.12)

forum management system as a portal module?

can someone check a db entry?

initial access to dotnetnuke dir. after install with ie dnn2b2

formview <insertitemtemplate datetime

collection property's items in inner tags for datagrid

 
All Times Are GMT