473,695 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel not updating

Here is a code for ASP inputs being updated in Excel. However, when I
click to submit the user, the excel does not get updated!

<% @Language="VBSc ript" %>

Dim con
Dim rst
Dim strCon
Dim strSQL
Dim name
Dim phone
Dim key
Dim goAhead
Dim myStr

Const adOpenKeyset = 1
Const adLockPessimist ic = 2

On Error Resume Next
name=Request("t xtPatientName")
phone=Request(" txtPhone")

For Each key In Request.Form
If Request.Form(ke y)= "" Then
If key = "txtPatientName " Then
Response.Write "<FONT Color = 'Blue'>"
Response.Write "Please enter the Patient name.</Font>"
Response.Write "<FONT Color = 'Red'>"
Response.Write "Please enter the Phone number.</Font>"
End If
goAhead = False
Exit For
End If

If goAhead = True Then
name=Replace(Re quest("txtPatie ntName"),"'","' '")
If Len(name)<0 Or _
Len(phone)<>0 Then
Set con = Server.CreateOb ject("ADODB.Con nection")
strCon="Provide r=Microsoft.Jet .OLEDB.4.0;Data Source="
strCon=strCon & server.MapPath( "ExcelDb.xl s") & ";"
strCon=strCon & "Extended Properties=Exce l 8.0"
If Request("cmdSub mit")="Enter Data in Excel" Then
strSQL = "INSERT INTO [Sheet1$] (Patient, Phone)"
strSQL = strSQL & " VALUES ('" & name & "'"
strSQL = strSQL & ",'" & Phone & "')"
End If
With con
.Open strCon
If Request("cmdDel ete")<>"Delete Data" Then
.Execute(strSQL )
set rst = Server.CreateOb ject("ADODB.Rec ordset")
rst.Open "Select * from [Sheet1$] Where Patient='" & _
name & "'" & _
" AND phone ='"& phone &"'", _
con, adOpenKeyset, adLockPessimist ic
rst.fields(0).v alue = ""
rst.fields(1).v alue = ""
End If
End With
If err.Number =3021 Then
Response.Write "The information you entered "
Response.Write "cannot be deleted." & "<BR>"
Response.Write "Either name or phone number "
Response.Write "is incorrect. " & "<P>"
name = ""
phone = ""
set rst = Server.CreateOb ject("ADODB.Rec ordset")
rst.Open "Select * from [Sheet1$]", con
Response.Write "<TABLE Border=""1"">"
For Each fld in rst.Fields
Response.Write "<TH>" & fld.Name & "</TH>"
Do While Not rst.EOF
Response.Write "<TR>"
For Each fld in rst.Fields
Response.Write "<TD>" & fld.Value & "</TD>"
Response.Write "</TR>"
Response.Write "</TABLE>"
Set rst=Nothing
Set con=Nothing
End If
End If
End If


<TITLE>Patien t Data Entry Screen</TITLE>
<FORM Action="ExcelEn try.asp" Method = "POST" Name="form1">
<TD>Patient Name: </TD>
<INPUT Type="text1" Name="txtPatien tName"
Value="<%=name% >" Size= "30">
<TD>Phone: </TD>
<INPUT Type="text2" Name="txtPhone"
Value="<%=phone %>">
<INPUT Type="Submit" Name="cmdSubmit "
Value="Enter Data in Excel">
<INPUT Type="Submit" Name="cmdDelete "
Value="Delete Data">
If err.number = 0 Then
If (Request("cmdSu bmit")="Enter Data in Excel" or _
Request("cmdDel ete") = "Delete Data") and _
Request.Form(ke y) <>"" Then
myStr = "The following data has been successfully "
If Request("cmdSub mit")="Enter Data in Excel" Then
Response.Write "<I><FONT Color = 'Green'>" & _
myStr & "added:</I></FONT><HR>"
ElseIf Request("cmdDel ete") = "Delete Data" Then
Response.Write "<I><FONT Color = 'Green'>" & _
myStr & "deleted:</I></FONT><HR>"
End If
End If
If Request("txtPat ientName") <>"" or _
Request("txtPho ne") <>"" Then
Response.Write "Patient Name: <B>" & _
Request("txtPat ientName") & "</B></P>"
Response.Write "Phone Number: <B>" & _
Request("txtPho ne") & "</B>"
End If
End If

Mar 21 '07 #1
0 1988

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Lize | last post by:
Hi, I'm writing an ASP application to open an excel workbook, then run a macro stored in the excel file, which produces outputs that will be displayed back onto my ASP application. Now the problem I'm having is whenever I try to open a workbook (of any format, i.e. 97/2000, 95, or xp, and of any size, and with or without macros), excel just hangs forever, and if I killed the excel application in task manager, my asp application will...
by: Mrs Howl | last post by:
I don't know if there's even a way to do what I want. I click on a button in an Access form, and it opens an instance of Excel, and opens a workbook and runs a macro that's in it. So far, fine, I know how to do this. I'm preferring to keep the Excel instance invisible, but while the macro is running, it would be nice to see some sort of progress indicator. (By the way, here's basically what the Excel macro is doing: it's opening...
by: trialproduct2004 | last post by:
Hi all i am having application storing data in excel sheet. This applicaton is in C# .net. I want to update rows of excel sheet in C#. Can some one help me how to do it. please help me. Thanks in advance.
by: Luis Esteban Valencia | last post by:
Hello Everyone, Iam an intermediate ASP.Net programmer and iam facing a challenging task. I have a table in MS-SQL server database called 'Members'. The table has following fields... mem_id integer primary key lastname nvarchar(30) firstname nvarchar(30)
by: Rich Wallace | last post by:
Hello all, Looking for suggestions and tips if possible. I have an application running on a file server that utilizes the FileSystemWatcher to trap when any Excel files are saved by a user. I then need to 'trap' the current file and generate an XML file from the data within the active spreadsheet. I have two issues so far with doing this... Issue 1: Once a file that is being watched is saved, I grab it using the
by: JaxDawg | last post by:
Hey folks... I've got an interesting problem. I'm updating and displaying an excel spreadsheet (using com) from a php file. Works great in the debugger (PhpEd 4.6), but not otherwise. I assume there must be a difference in PHP versions in effect here. Instantiating com, opening workbook, activating sheet, selecting cell, activating cell all work just fine... but when I try to set the cell value, I just get "waiting on localhost" and it...
by: somanyusernamesaretakenal | last post by:
What I am trying to achieve: Basically I have generated a report in access. This report needs to be updated using excel. (Updating the new data, not changing existing data) What I did was I imported the existing report into Excel (Tools – Office Links – Analyze It with MS Excel). Then I linked the report to the Excel file. (File – Get External Data – Link tables) and a link table was automatically generated. I wanted to test the link,...
by: bbasberg | last post by:
Hello, I have been struggling with this problem for DAYS and have googled my heart out as well as reading any books I could get my hands on but I cannot find any specific references to my problem. I have been able to successfully loop through a directory reading spreadsheets that insert records into an Access database. The spreadsheets in said directory are all of the same format but have different values in the cells. It's when I turned...
by: Neil Chambers | last post by:
This is more likely a question for an SQL group but as I'm using powershell and dotnet it may be relevant Overview: I'm trying to pull data from Excel into a DataSet - modifying the DataSet - then updating the excel source I have got to the point where I think I need Update and Delete Command strings for the DataAdapter but I'm at a loss as to what to do
by: joolzhaines | last post by:
Hi, Does anyone know how to sort an excel speadsheet? I have a C# app that does almost everything else but when I try and sort I get an ojbect reference error! I have tried running excel and record a macro but the resulting code is uncomplete and only has 9 args and the C# will not run unless all are specified correctly. ... oSheet.get_Range("A2", "M" + intLastRow).Select(); oSheet.Rows.Sort("A2", Excel.XlSortOrder.xlAscending,...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.