access db to sql db rewright

I am changing a page from Access to SQL express database.  I usually use Dreamweaver Datasets and no problem with them but my hit counter is different.  Can someone rewright this code to work with a SQL database?  If t is possable to use it with a dreamweaver dataset that would be even better but i will take what I can get to learn.

Thanks
Rusty

 _________________________________________________________________

<%@ Page Language="vb" Debug=false %>
<%@ import Namespace="System.Data.OLEDB" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<%@ import Namespace="System.Drawing.Text" %>

<script runat="server" language="vb">
    Sub Page_Load(sender As Object, e As EventArgs)
  Dim queryvalue = Request.QueryString("id")
        If (IsNumeric(queryvalue)) then

            'set the size of your image
            Dim aWidth As Integer = 60
            Dim aHeight As Integer = 30

            'set the background of the image
            Dim aBgColor As Drawing.Color = Drawing.Color.White

            'get the counter number to appear on the image.
   Dim aText As String
            atext = hitcounter(queryvalue)' & vbcrlf & "homescoop.com"
   
            'set the font etc...
            Dim aFont As New Drawing.Font("Arial", 18, Drawing.FontStyle.Regular, Drawing.GraphicsUnit.Pixel)
            Dim aFontColor As Drawing.Color = Drawing.Color.Black

            Dim b As New Drawing.Bitmap(aWidth, aHeight, Drawing.Imaging.PixelFormat.Format24bppRgb)
            Dim g As Drawing.Graphics = Drawing.Graphics.FromImage(b)
            g.Clear(aBgColor)
            g.SmoothingMode = Drawing.Drawing2D.SmoothingMode.AntiAlias

            'StringFormat to center the text on the image.
            Dim SFormat As New Drawing.StringFormat
            SFormat.Alignment = Drawing.StringAlignment.Center

            g.DrawString(aText, aFont, New Drawing.SolidBrush(aFontColor), b.Width / 2, 5, SFormat)

            Response.Clear()
            Response.ContentType = "Image/Gif"
   'output the image to the users screen
            b.Save(Response.OutputStream, Drawing.Imaging.ImageFormat.Gif)
   'clean up
            b.Dispose()
            Response.Flush()
            Response.End()
        End If
end sub

    Function hitcounter(ByVal queryvalue As Integer)
  dim datapath as String
  'SET THE PATH TO YOUR DATABASE HERE!!
  datapath = Server.MapPath("/database/properties.mdb")
 
        Dim query As String = "Select cvalue from hscounter where id = " & queryvalue & ";"
        Dim myConn As New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & datapath)
        Dim myCmd As OleDbCommand = New OleDbCommand(query, myConn)
        myConn.Open()
        Dim myReader As OleDbDataReader = myCmd.ExecuteReader()

        Dim newcount As Integer
        While myReader.Read()
            newcount = (myReader("cvalue"))
        End While

        'close connections
        myReader.Close()
        myConn.Close()

        'now update the database
        Dim newcountadd As Integer = (newcount + 1)
        Dim updatequery As String = "UPDATE hscounter SET cvalue = " & newcountadd & " where id = " & queryvalue & ";"
        Dim myCommand As New OleDbCommand(updatequery, myConn)
        myCommand.Connection.Open()
        myCommand.ExecuteNonQuery()
        myConn.Close()

        'set the hitcount value from the function
  hitcounter = newcount
    End Function

</script>

0
abyss42
1/31/2008 9:28:50 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
764 Views

Similar Articles

[PageSpeed] 20

So this isn't possible i am guessing... does anyone have simple SQL database code that can do a auto update so I can track visitors on a website.  It would be really nice if I could use a dreamweaver dataset.

 

Thanks

0
abyss42
2/5/2008 4:37:15 PM
Reply:

Similar Artilces:

Convert from Access DB to SQL DB....
Dear All,  I would like to convert from Access To SQL DB undervisual Studio.Net 2005... How can I do it easily, or if there any software to do this automaticlly, please your help..  Awaiting your valuable reply. Many thanks in advance for your cooperation and continuous support....Aح What version of MS Access are you using?Most of the Access versions like XP/2003 all have an upgrade wizard that allows you to convert your existing database to SQL Server.In Access 2003 I believe you can use the Upsizing Wizard which can be accessed from Tools -> Database Utilities -> Upsi...

Access DB instead of SQL DB?
Hi folks, Is it possible to set up a Membership-Type Access DataBase in the same manner as an SQL DataBase with ASP.NET automatically configuring all of the DataBase components so that the DataBase will be the same as an SQL DataBase? In other words, could I do something like create an empty .mdb file, put it in the App_Data folder, and ASP.NET will set up the Tables, Views, Functions, etc. and configure it as I add the Login, Password, etc. Controls? Many Thanks. hypercode: Hi folks, Is it possible to set up a Membership-Type Access DataBase in the...

Convert SQL Server DB to Access DB
Hi, I'm trying to convert a SQL Server 2000 database into a Access database because my hosting provider does not support SQL Server. I have tried the DTS, however it can only convert the tables, not the stored procedures. So is it possible to convert the stored procedures as well? I'm looking forwards to your response Phan Nguyen Hello, I believe you need some third-party components to do so, check the links below: MSSQL-to-Access 1.0 MSSQL Migration Toolkit v1.0 All are shareware tools, yuo can download and use them as a trial version. Regards.Bilal Hadiar, MCP, MCTS,...

How to keep SQL DB and Access DB syncronised
Hi, I have a project which i'm trying to do for a client. It starts with an access database on the local client machine, plenty of fields but the main ones are DealerID, VehicleID, Make, Model There is also an SQL server on the internet which drives a website, it has the same fields, DealerID, VehicleID, Make, Model. I need to write an application that reads the local access file and updates the SQL server. What is the best way to do this?, At first I thought delete everything from SQL server then upload everything from Access but that doesn't seem like the best way, Really I ...

BCP Sybase SQL Server db to SQL Anywhere db?
Anyone, I am searching for an automated way to take an entire Sybase SQL Server db on a Unix server and get it into a Sybase SQL Anywhere db on my laptop. I dont feel like going table by table through the Pipeline not to mention that I have RI proplems with this approach as well. Ideally, I would like to have explained to me a way to perform a BCP from the Unix SQL Server world into the windows based SQL Anywhere world. If this is even possible. The model itself is not as important as the data because we use ERwin and I am able to forward engineer the model onto the SQL Anywhe...

BCP Sybase SQL Server db to SQL Anywhere db?
Anyone, I am searching for an automated way to take an entire Sybase SQL Server db on a Unix server and get it into a Sybase SQL Anywhere db on my laptop. I dont feel like going table by table through the Pipeline not to mention that I have RI proplems with this approach as well. Ideally, I would like to have explained to me a way to perform a BCP from the Unix SQL Server world into the windows based SQL Anywhere world. If this is even possible. The model itself is not as important as the data because we use ERwin and I am able to forward engineer the model onto the SQL Anywhe...

BCP Sybase SQL Server db to SQL Anywhere db?
Anyone, I am searching for an automated way to take an entire Sybase SQL Server db on a Unix server and get it into a Sybase SQL Anywhere db on my laptop. I dont feel like going table by table through the Pipeline not to mention that I have RI proplems with this approach as well. Ideally, I would like to have explained to me a way to perform a BCP from the Unix SQL Server world into the windows based SQL Anywhere world. If this is even possible. The model itself is not as important as the data because we use ERwin and I am able to forward engineer the model onto the SQL Anywhe...

Changing access db to sql db web application.
I am experiencing problems with databases for the web application that i am developing. The problem is that I have transferred the database from access to sql which initially seemed to work ok. I am now however struggling to solve the problems with one of my fields titled 'notes'. The trouble is that in the original database the notes field contained different notes from different dates for each record, and each note is separated by carriage returns. It is the carriage returns that are now proving to be a problem in the sql database but i am not sure what to do. Any advice would be appreciat...

In WSS Backing up DB of SQL 2005 and restore in DB of SQL 2000 giving error
Hi, sometime ago, I have installed WSS and configured using typical option whereby be default SQL server 2005 used for creating the content DB. Later I realize that I need to use SQL 2000 instead because of licensing problem. Therefore, I have re-installed the WSS but now using advanced options and selected SQL 2000 instead. Earlier when using SQL 2005, I have created nearly a complete site and backed up the whole farm. Now with the newly installed WSS, when I try to restore the backed up WSS farm, the restore process giving error saying “the backed up DB is using structure version 611 but c...

Transfering tables and data from one MS SQL DB to another MS SQL DB
I need to transfer tables and data from one SQL DB to another SQL DB. I know it can be done with Server Management Studio and I have searched Studio and Help but can't find any info on the database migration wizard. Hi,jayd  Follow This Link U can Get Help From This For Ur Case    http://forums.asp.net/t/1352620.aspx   PLZ MARK AS ANSWER IF IT HELP U. THANKS. RAGHAV MVP ASP/ASP.Net Read My Blog MARK THE POST AS ANSWER IF IT HELPS U. "Success doesn't come to you…you go to it."--Marva Collins "Success does not come to those who w...

How do I synchronise local SQL Server Express db with my online SQL Server 2005 db?
For various reasons, I have a situation where the data in the SQL Server 2005 database hosted by my ISP is more up to date than the data in the matching SQL Server Express database on my own PC. I now want to synchronise these two databases but don't know how to do it. Because I am still developing my ASP.NET 3.5 app, which has not yet been opened up to users, I am only used to synchronising in the other direction by first using the Database Publishing Wizard within Visual Web Developer 2008 Express to create a suitable script associated with my SQL Server Express database and then runn...

Attach SQL DB to SQL Server 2005 using VB.Net
Is there any way to attach a SQL DB to SQL Server 2005 using VB.Net?  If so can you also set security? Can you rephrase your question? Attach SQL DB from which version of SQL server ? Look up books online for sp_attachdb and sp_detachdb.***********************Dinakar NethiLife is short. Enjoy it.*********************** I have a DB that was created in SQL Server 2005.  I have a website that displays data from systems all over the world.  Each system sends it's data to it's own DB.  The customer can then go to a website and see the data at real time.  What ...

Howto: Convert sample SQL dB code to Access dB code?
Hello, In reference to the book: ASP.NET Web Matrix Starter Kit (ISBN: 0-7356-1856-9) Chapter 14 – Creating a Web-Based Calendar. The sample code works great when using an SQL server dB. However Web Matrix allows us to use an Access dB as well. My question is how do I convert the code found on page 275 to work with an Access dB? I have got the rest of the sample code in this chapter to work using Access, but I am not familiar with the proper way to convert this code: Sub DisplayAppointments(dateToDisplay As DateTime) labelSelectedDate.Text = dateToDisplay...

Using the AS in a SQL query accessing an Access DB
Hello, I'm using a Asp.Net GridView for the first time and am VERY pleased with how easy it is to set up. However, I'm running into a couple of simple problems. First, my query looks like this: sql.Append("SELECT DISTINCT a As 'something somthing' ...") My problem is that when I view the grid, the single quotes actually show up. When I eliminate them, no results are found (because of the spaces). How do I get around this? Also, I selected the features Edit and Delete in the GridView (using VWD Express). How do I go about actually implementing those? I am g...

Web resources about - access db to sql db rewright - asp.net.sql-datasource

Resources last updated: 1/22/2016 9:10:51 AM