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>"
Else
Response.Write "<FONT Color = 'Red'>"
Response.Write "Please enter the Phone number.</Font>"
End If
goAhead = False
Exit For
End If
GoAhead=True
Next

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 )
Else
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 = ""
rst.Update
rst.Close
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>"
Else
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>"
Next
rst.MoveFirst
Do While Not rst.EOF
Response.Write "<TR>"
For Each fld in rst.Fields
Response.Write "<TD>" & fld.Value & "</TD>"
Next
Response.Write "</TR>"
rst.MoveNext
Loop
Response.Write "</TABLE>"
rst.Close
Set rst=Nothing
con.Close
Set con=Nothing
End If
End If
End If

%>

<HR>
<HTML>
<HEAD>
<TITLE>Patien t Data Entry Screen</TITLE>
</HEAD>
<BODY>
<FORM Action="ExcelEn try.asp" Method = "POST" Name="form1">
<P>
<TABLE BORDER="1" CELLPADDING="2" CELLSPACING="4" >
<TR>
<TD>
<TABLE BORDER="1" CELLPADDING="2" CELLSPACING="3" >
<TR>
<TD>Patient Name: </TD>
<TD>
<INPUT Type="text1" Name="txtPatien tName"
Value="<%=name% >" Size= "30">
</TD>
</TR>
<TR>
<TD>Phone: </TD>
<TD>
<INPUT Type="text2" Name="txtPhone"
Value="<%=phone %>">
</TD>
</TR>
<INPUT Type="Submit" Name="cmdSubmit "
Value="Enter Data in Excel">
<INPUT Type="Submit" Name="cmdDelete "
Value="Delete Data">
</TABLE>
</TD>
<TD>
<%
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
%>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>

Mar 21 '07 #1
0 1988

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

Similar topics

1
6385
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...
2
11103
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...
1
4367
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.
1
2462
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)
0
2242
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
1
1997
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...
4
3341
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,...
11
5767
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...
1
1779
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
0
852
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,...
0
8578
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,...
0
8998
jinu1996
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...
1
8857
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,...
0
5841
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();...
0
4346
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...
0
4586
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3013
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
2
2278
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1979
bsmnconsultancy
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.