Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to File 1

Status
Not open for further replies.

Reynet01

Technical User
Apr 27, 2004
59
US
I have a response.write statement on my page that writes out a license code string which looks like this

[RTAuth]
XXXXXXX=RTVoiceLines=0120-XXXXXXXXXX

Here is the code
<%response.Write"[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>

I would like to know if their is way to export this license string to a file where the user can click a link and download the license file the name of the file would be vblicense.ini "it is nothing but a text file with the license string in it" Thanks for any help

If knowledge were power I would be a AAA battery!
 
not completely sure...

Code:
<%
dim mylicense
mylicense=<%response.Write"[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>

dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("c:\test.txt",true)
fname.WriteLine(mylicense)
fname.Close
set fname=nothing
set fs=nothing
%>

that is how is write to a text file..can you explain a little more...

-DNG
 
oops...copy paste errors :)

should be ...

mylicense="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))

-DNG
 
Thanks for the response.
Here is the link to the page

in the table cell where it shows the License string I would like to provide a download link to the user the link would be to a file named vblicense.ini and would have this license string in the file

If knowledge were power I would be a AAA battery!
 
ok here we go...when you do a response.write your license number in the table...do this...

presently you may be having something like...

<td><%=licensenumber</td>

change it to look like this....

<td><a href= "#" ONCLICK = 'downloadfile("<%=licensenumber%>")'>licensenumber</a></td>

now in the end on the same page...have this function...

<script language="VBscript">
Sub ViewDetail(licensenumber)
Window.Open "mypage.asp?licensenumber="&licensenumber
End Sub
</script>

now on mypage.asp...put this code...

Code:
<%
filename="vblicense.ini"
response.contenttype="text/plain"

Response.AddHeader "content-disposition", "attachment; filename=""" & fileName & """"
dim myvar
myvar=request.querystring("licensenumber")
response.write myvar
%>

when you click the link the user will be prompted for downloading the file name vblicense.ini which will have the license number in it...

-DNG
 
inside the vb script sub i had a typo...

<script language="VBscript">
Sub [red]downloadfile[/red](licensenumber)
Window.Open "mypage.asp?licensenumber="&licensenumber
End Sub
</script>

-DNG
 
if you have any problems post it here...and if you have any problems linking your original code with the code i provided...just do this simple thing...put the below code in test.asp file

Code:
<%
filename="vblicense.ini"
response.contenttype="text/plain"

Response.AddHeader "content-disposition", "attachment; filename=""" & fileName & """"
dim myvar
myvar=myvar="[RTAuth]3UA5ZCY=RTVoiceLines=0002-4A6QZCERE0 "
response.write myvar
%>

and run it...

and see the output...

-DNG
 
Thanks I am getting a error you can see it if you go there

Here is the code from the page What am I doing wrong?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/RS1.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_RS1_STRING
MM_editTable = "dbo.Pronexus"
MM_editRedirectUrl = "pronexus.asp"
MM_fieldsStr = "txtcompany|value|txtlicensecode|value|txtports|value|txtdate|value|txtactcode|value"
MM_columnsStr = "Company|',none,''|LicenseCode|',none,''|Ports|',none,''|DateofIssue|',none,NULL|actcode|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_RS1_STRING
Recordset1.Source = "SELECT * FROM dbo.Pronexus"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>VB Licenses</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="Left">
<p align="center"><font size="5"> License Management</font></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form name="form1" method="POST" action="<%=MM_editAction%>">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="39%"><div align="center"><strong>Company</strong></div></td>
<td width="19%"><div align="center"><strong>License Code</strong></div></td>
<td width="20%"><div align="center"><strong>Number of Ports</strong></div></td>
<td width="22%"><div align="center"><strong>ActCode</strong></div></td>
<td width="22%"><div align="center"><strong>Date of Issue</strong></div></td>
</tr>
<tr>
<td><div align="center">
<input name="txtcompany" type="text" id="txtcompany" size="30" maxlength="50">
</div></td>
<td><div align="center">
<input name="txtlicensecode" type="text" id="txtlicensecode">
</div></td>
<td><div align="center">
<input name="txtports" type="text" id="txtports">
</div></td>
<td><div align="center">
<input name="txtactcode" type="text" id="txtactcode2">
</div></td>
<td><div align="center">
<input name="txtdate" type="text" id="txtdate4">
</div></td>
</tr>
<tr>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td> <div align="center"></div></td>
<td><div align="center">
<input type="submit" name="Submit" value="Enter New Record">
</div></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
Test page enter any info
</form>
<p>&nbsp;</p>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="31%"><div align="center">Company</div></td>
<td width="14%"><div align="center">Ports</div></td>
<td width="14%"><div align="center">Date of Issue</div></td>
<td width="41%"><div align="center">License String</div></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td><%=(Recordset1.Fields.Item("Company").Value)%></td>
<td><%=(Recordset1.Fields.Item("Ports").Value)%></td>
<td><%=(Recordset1.Fields.Item("DateofIssue").Value)%></td>
<td><a href= "#" ONCLICK = 'downloadfile( <%response.Write"[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>)'>licensenumber</a></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="left">&nbsp;</p>
</div>


</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<script language="VBscript">
Sub downloadfile(licensenumber)
Window.Open "mypage.asp?licensenumber="&licensenumber
End Sub
</script>

If knowledge were power I would be a AAA battery!
 
try this:
Code:
<td><a href= "#" ONCLICK = 'downloadfile( <%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>)'></a><%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%></td>
and in your function....
Code:
<script language="VBscript">
Sub downloadfile(licensenumber)
Window.Open "mypage.asp?licensenumber='"&licensenumber&"'
End Sub
</script>

also show me the mypage.asp code you have...

-DNG
 
oops...</a> tags are not in the right place...just be before </td> tags....

-DNG
 
should be :

<td><a href= "#" ONCLICK = 'downloadfile( <%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>)'><%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>[red]</a>[/red]</td>

-DNG
 
Sorry I still get an error
here is the mypage.asp code

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
filename="vblicense.ini"
response.contenttype="text/plain"

Response.AddHeader "content-disposition", "attachment; filename=""" & fileName & """"
dim myvar
myvar="[RTAuth]3UA5ZCY=RTVoiceLines=0002-4A6QZCERE0 "
response.write myvar
%>


Here is the example.asp code with the new code you gave me. By the way thank you for being so patient with me.


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/RS1.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_RS1_STRING
MM_editTable = "dbo.Pronexus"
MM_editRedirectUrl = "pronexus.asp"
MM_fieldsStr = "txtcompany|value|txtlicensecode|value|txtports|value|txtdate|value|txtactcode|value"
MM_columnsStr = "Company|',none,''|LicenseCode|',none,''|Ports|',none,''|DateofIssue|',none,NULL|actcode|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_RS1_STRING
Recordset1.Source = "SELECT * FROM dbo.Pronexus"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>VB Licenses</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="Left">
<p align="center"><font size="5"> License Management</font></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form name="form1" method="POST" action="<%=MM_editAction%>">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="39%"><div align="center"><strong>Company</strong></div></td>
<td width="19%"><div align="center"><strong>License Code</strong></div></td>
<td width="20%"><div align="center"><strong>Number of Ports</strong></div></td>
<td width="22%"><div align="center"><strong>ActCode</strong></div></td>
<td width="22%"><div align="center"><strong>Date of Issue</strong></div></td>
</tr>
<tr>
<td><div align="center">
<input name="txtcompany" type="text" id="txtcompany" size="30" maxlength="50">
</div></td>
<td><div align="center">
<input name="txtlicensecode" type="text" id="txtlicensecode">
</div></td>
<td><div align="center">
<input name="txtports" type="text" id="txtports">
</div></td>
<td><div align="center">
<input name="txtactcode" type="text" id="txtactcode2">
</div></td>
<td><div align="center">
<input name="txtdate" type="text" id="txtdate4">
</div></td>
</tr>
<tr>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td> <div align="center"></div></td>
<td><div align="center">
<input type="submit" name="Submit" value="Enter New Record">
</div></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
Test page enter any info
</form>
<p>&nbsp;</p>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="31%"><div align="center">Company</div></td>
<td width="14%"><div align="center">Ports</div></td>
<td width="14%"><div align="center">Date of Issue</div></td>
<td width="41%"><div align="center">License String</div></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td><%=(Recordset1.Fields.Item("Company").Value)%></td>
<td><%=(Recordset1.Fields.Item("Ports").Value)%></td>
<td><%=(Recordset1.Fields.Item("DateofIssue").Value)%></td>
<td><a href= "#" ONCLICK = 'downloadfile( <%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>)'></a><%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%></td>

</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="left">&nbsp;</p>
</div>


</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<script language="VBscript">
Sub downloadfile(licensenumber)
Window.Open "mypage.asp?licensenumber='"&licensenumber&"'
End Sub
</script>



If knowledge were power I would be a AAA battery!
 
did u see the change i suggested in the previous post...we had </a> tags in the wrong place...

-DNG
 
Yes I checked that but still a error





<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/RS1.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_RS1_STRING
MM_editTable = "dbo.Pronexus"
MM_editRedirectUrl = "pronexus.asp"
MM_fieldsStr = "txtcompany|value|txtlicensecode|value|txtports|value|txtdate|value|txtactcode|value"
MM_columnsStr = "Company|',none,''|LicenseCode|',none,''|Ports|',none,''|DateofIssue|',none,NULL|actcode|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_RS1_STRING
Recordset1.Source = "SELECT * FROM dbo.Pronexus"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>VB Licenses</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="Left">
<p align="center"><font size="5"> License Management</font></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form name="form1" method="POST" action="<%=MM_editAction%>">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="39%"><div align="center"><strong>Company</strong></div></td>
<td width="19%"><div align="center"><strong>License Code</strong></div></td>
<td width="20%"><div align="center"><strong>Number of Ports</strong></div></td>
<td width="22%"><div align="center"><strong>ActCode</strong></div></td>
<td width="22%"><div align="center"><strong>Date of Issue</strong></div></td>
</tr>
<tr>
<td><div align="center">
<input name="txtcompany" type="text" id="txtcompany" size="30" maxlength="50">
</div></td>
<td><div align="center">
<input name="txtlicensecode" type="text" id="txtlicensecode">
</div></td>
<td><div align="center">
<input name="txtports" type="text" id="txtports">
</div></td>
<td><div align="center">
<input name="txtactcode" type="text" id="txtactcode2">
</div></td>
<td><div align="center">
<input name="txtdate" type="text" id="txtdate4">
</div></td>
</tr>
<tr>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td> <div align="center"></div></td>
<td><div align="center">
<input type="submit" name="Submit" value="Enter New Record">
</div></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
Test page enter any info
</form>
<p>&nbsp;</p>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="31%"><div align="center">Company</div></td>
<td width="14%"><div align="center">Ports</div></td>
<td width="14%"><div align="center">Date of Issue</div></td>
<td width="41%"><div align="center">License String</div></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td><%=(Recordset1.Fields.Item("Company").Value)%></td>
<td><%=(Recordset1.Fields.Item("Ports").Value)%></td>
<td><%=(Recordset1.Fields.Item("DateofIssue").Value)%></td>
<td><a href= "#" ONCLICK = 'downloadfile( <%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>)'><%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%></a></td>

</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="left">&nbsp;</p>
</div>


</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<script language="VBscript">
Sub downloadfile(licensenumber)
Window.Open "mypage.asp?licensenumber='"&licensenumber&"'
End Sub
</script>

If knowledge were power I would be a AAA battery!
 
can you please show me the code you have in the mypage.asp file...because in our function we are referring to this page...

did you see that...

Window.Open "[red]mypage.asp[/red]?licensenumber='"&licensenumber&"'

now if you havent coded that yet...here is the code for that page...

Code:
<%
filename="vblicense.ini"
response.contenttype="text/plain"

Response.AddHeader "content-disposition", "attachment; filename=""" & fileName & """"
dim myvar
myvar=request.querystring("licensenumber")
response.write myvar
%>

post back if you have any more questions...

-DNG
 
heres the code for mypage.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
filename="vblicense.txt"
response.contenttype="text/plain"

Response.AddHeader "content-disposition", "attachment; filename=""" & fileName & """"
dim myvar
myvar=request.querystring("licensenumber")
response.write myvar
%>


</body>
</html>

If knowledge were power I would be a AAA battery!
 
just delete all the stuff striked out
Code:
[s][red]<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>[/red][/s]
<%
filename="vblicense.txt"
response.contenttype="text/plain"

Response.AddHeader "content-disposition", "attachment; filename=""" & fileName & """"
dim myvar
myvar=request.querystring("licensenumber")
response.write myvar
%>

[s][red]
</body>
</html> [/red][/s]

-DNG
 
be online and check this post constantly...i will check too..lets solve it...

-DNG
 
oops..

filename="vblicense.[red]txt[/red]" should be

filename="vblicense.[red]ini[/red]"

-DNG
 
Ok here is the code for the example.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/RS1.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_RS1_STRING
MM_editTable = "dbo.Pronexus"
MM_editRedirectUrl = "pronexus.asp"
MM_fieldsStr = "txtcompany|value|txtlicensecode|value|txtports|value|txtdate|value|txtactcode|value"
MM_columnsStr = "Company|',none,''|LicenseCode|',none,''|Ports|',none,''|DateofIssue|',none,NULL|actcode|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_RS1_STRING
Recordset1.Source = "SELECT * FROM dbo.Pronexus"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<title>VB Licenses</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div align="Left">
<p align="center"><font size="5"> License Management</font></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form name="form1" method="POST" action="<%=MM_editAction%>">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="39%"><div align="center"><strong>Company</strong></div></td>
<td width="19%"><div align="center"><strong>License Code</strong></div></td>
<td width="20%"><div align="center"><strong>Number of Ports</strong></div></td>
<td width="22%"><div align="center"><strong>ActCode</strong></div></td>
<td width="22%"><div align="center"><strong>Date of Issue</strong></div></td>
</tr>
<tr>
<td><div align="center">
<input name="txtcompany" type="text" id="txtcompany" size="30" maxlength="50">
</div></td>
<td><div align="center">
<input name="txtlicensecode" type="text" id="txtlicensecode">
</div></td>
<td><div align="center">
<input name="txtports" type="text" id="txtports">
</div></td>
<td><div align="center">
<input name="txtactcode" type="text" id="txtactcode2">
</div></td>
<td><div align="center">
<input name="txtdate" type="text" id="txtdate4">
</div></td>
</tr>
<tr>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td><div align="center"></div></td>
<td> <div align="center"></div></td>
<td><div align="center">
<input type="submit" name="Submit" value="Enter New Record">
</div></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
Test page enter any info
</form>
<p>&nbsp;</p>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="31%"><div align="center">Company</div></td>
<td width="14%"><div align="center">Ports</div></td>
<td width="14%"><div align="center">Date of Issue</div></td>
<td width="41%"><div align="center">License String</div></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td><%=(Recordset1.Fields.Item("Company").Value)%></td>
<td><%=(Recordset1.Fields.Item("Ports").Value)%></td>
<td><%=(Recordset1.Fields.Item("DateofIssue").Value)%></td>
<td><a href= "#" ONCLICK = 'downloadfile( <%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>)'><%="[RTAuth]"+"<BR>"+((Recordset1.Fields.Item("LicenseCode").Value)+"=RTVoiceLines="+(Recordset1.Fields.Item("Ports").Value)+"-"+(Recordset1.Fields.Item("actcode").Value))%>licensenumber</a></td>

</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="left">&nbsp;</p>
</div>

<script language="VBscript">
Sub downloadfile(licensenumber)
Window.Open "mypage.asp?licensenumber='"&licensenumber&"'
End Sub
</script>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>



Here is the code for mypage.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
filename="vblicense.ini"
response.contenttype="text/plain"

Response.AddHeader "content-disposition", "attachment; filename=""" & fileName & """"
dim myvar
myvar=request.querystring("licensenumber")
response.write myvar
%>

</html>




If knowledge were power I would be a AAA battery!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top