|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Good day,
I made a web application (asp.net) that will allow the user to export data from sql server to MS Word, luckily I am able to run the web app on my machine. Unfortunately, when i tried it on a client machine an authorization box pops-up on my screen asking me to input a username and password that will allow me to access the server. I placed the default username and password which is IUSR{computername}. I get an access denied error. Hope someone could help me on this. Thanks/Regards, Paw |
|
#2
|
||||
|
||||
|
Please don't double post your questions
![]() So you don't get access to the sql server from the client machine? did you change your connection string to access the server on a different machine?
__________________
Look! Its a ShemZilla ![]() ![]()
|
|
#3
|
|||
|
|||
|
Quote:
Hi nofriends, sorry about that. nope I didn't changed my connection string to access the server on a different machine. My queries are all working fine and I am able to generate a result set except that I am not able to export these (result set) to an excel file or word file on a client machine.Thanks, Paw |
|
#4
|
||||
|
||||
|
Make sure that the IUSR_<%MachineName%> has the correct rights in the folder that you are trying to export the excel and word file, that should do the trick
![]() |
|
#5
|
|||
|
|||
|
Quote:
Thanks nofriends...but my problem is not my linkbutton to export the files but the calling of the excel application in client side or locally. When I click my linkbutton to export in my machine it works properly but if i already click the button(Export linkButton) in other machine there's a authentication message box asking for a username and password of the client to connect on my machine. Thank you very much nofriends! paw ![]() |
|
#6
|
||||
|
||||
|
could you paste the relevent code?
|
|
#7
|
||||
|
||||
|
its sounds like your are trying to create the file on your machine, instead of the client machine?
|
|
#8
|
|||
|
|||
|
Quote:
sure!This is the code of my linkbutton to export the content of my datagrid to excel: Code:
Dim priorSum As Integer = 0
Dim newSum As Integer = 0
Dim xlProcID As Integer = 0
Dim dt As New DataTable
'Dim tw As New System.IO.StringWriter
'Dim hw As New System.Web.UI.Html32TextWriter(tw)
dt = Session("Results")
For Each proc1 As Process In Process.GetProcessesByName("excel")
priorSum += proc1.Id
Next proc1
Dim excelApp As New Excel.Application
Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add
'excelapp.ActiveWindow
Dim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1), Excel.Worksheet)
Dim excelCharts As Excel.ChartObjects = _
CType(excelWorksheet.ChartObjects(), Excel.ChartObjects)
excelApp.Visible = True
With excelWorksheet
' Set the column headers and desired formatting for the spreadsheet.
.Columns().ColumnWidth = 21
.Range("A1").Value = "File Reference No."
.Range("A1").Font.Bold = True
.Range("A1").Font.Size = 8
.Range("A1").Font.Color = RGB(255, 255, 255)
.Range("A1").Interior.Color = RGB(0, 0, 0)
.Range("B1").Value = "Name"
.Range("B1").Font.Bold = True
.Range("B1").Font.Size = 8
.Range("B1").Font.Color = RGB(255, 255, 255)
.Range("B1").Interior.Color = RGB(0, 0, 0)
.Range("C1").Value = "Social Security Number"
.Range("C1").Font.Bold = True
.Range("C1").Font.Size = 8
.Range("C1").Font.Color = RGB(255, 255, 255)
.Range("C1").Interior.Color = RGB(0, 0, 0)
.Range("D1").Value = "First Position Desired"
.Range("D1").Font.Bold = True
.Range("D1").Font.Size = 8
.Range("D1").Font.Color = RGB(255, 255, 255)
.Range("D1").Interior.Color = RGB(0, 0, 0)
.Range("E1").Value = "Second Position Shift"
.Range("E1").Font.Bold = True
.Range("E1").Font.Size = 8
.Range("E1").Font.Color = RGB(255, 255, 255)
.Range("E1").Interior.Color = RGB(0, 0, 0)
.Range("F1").Value = "Date"
.Range("F1").Font.Bold = True
.Range("F1").Font.Size = 8
.Range("F1").Font.Color = RGB(255, 255, 255)
.Range("F1").Interior.Color = RGB(0, 0, 0)
excelWorksheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape
' Start the counter on the second row, following the column headers
Dim i As Integer = 2
' Loop through the Rows collection of the DataSet and write the data
' in each row to the cells in Excel.
Dim dr As DataRow
Dim intTotal, iFooter As Integer
If Not dt.DataSet.Tables(0).Rows.Count > 0 Then
Exit Sub
End If
For Each dr In dt.DataSet.Tables(0).Rows
intTotal = 0
'MsgBox(dr(0))
.Range("A" & i.ToString).Value = dr(0)
.Range("A" & i.ToString).Font.Size = 8
.Range("B" & i.ToString).Value = dr(1)
.Range("B" & i.ToString).Font.Size = 8
.Range("C" & i.ToString).Value = dr(2)
.Range("C" & i.ToString).Font.Size = 8
.Range("D" & i.ToString).Value = dr(3)
.Range("D" & i.ToString).Font.Size = 8
.Range("E" & i.ToString).Value = dr(4)
.Range("E" & i.ToString).Font.Size = 8
.Range("F" & i.ToString).Value = dr(5)
.Range("F" & i.ToString).Font.Size = 8
i += 1
Next
'TODO: Create a configurable path.
'
Dim path As String = "c:\Export\Excel"
If File.Exists(path) Then
File.Delete(path)
End If
Dim dateGenerated As Date
path += Replace(dateGenerated.Now.ToShortDateString, "/", "") & Replace(dateGenerated.Now.ToShortTimeString.Replac e(" ", ""), ":", "")
path += ".xls"
b = path
Session("AttachFile") = b
excelWorksheet.SaveAs(path)
For Each proc2 As Process In Process.GetProcessesByName("excel")
newSum += proc2.Id
Next proc2
xlProcID = newSum - priorSum
'Get the process ID of the Excel application
Dim proc As Process = Process.GetProcessById(xlProcID)
'If excelApp.Visible = False Then
proc.WaitForExit(120000)
proc.Kill()
'End If
nofriends this is the error i encountered when i already use my linkbutton in other machine: Access is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access. Source Error: Line 74: Next proc1 Line 75: Line 76: Dim excelApp As New Excel.Application Line 77: Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add Line 78: 'excelapp.ActiveWindow Source File: c:\inetpub\wwwroot\Personnel\Menu.ascx.vb Line: 76 Stack Trace: [UnauthorizedAccessException: Access is denied.] Personnel.Menu.lnkbtnExport_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\Personnel\Menu.ascx.vb:76 System.Web.UI.WebControls.LinkButton.OnClick(Event Args e) System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) System.Web.UI.Page.ProcessRequestMain() Thank you so much nofriends. ![]() Last edited by Shadow Wizard : June 30th, 2005 at 04:08 AM. Reason: added code tags - please do it yourself with [code] and [/code] tags next. |
|
#9
|
||||
|
||||
|
This is ASP.Net, I am a total n00b at this
![]() I will get someone to have a look at this, just hold on ![]() |
|
#10
|
|||
|
|||
|
Quote:
Yes it is nofriends! The data is from the server using asp.net application to retrieve it, the user then has an option if he wants to save the data to an excel file right unto his local machine (client). Whenever I try it on my client test machine I was always asked to input a username and password under the server machine's domain. The question is, how will I enable a client user to call it's local excel application? Thanks, paw ![]() |
|
#11
|
|||
|
|||
|
Quote:
OK!Thank you nofriends! |
|
#12
|
||||
|
||||
|
please wrap your code with code tags in the future. ([ code] and [ /code] tags)
anyway, make sure that Anonymous Access is enabled on the server. (Internet Services Manager --> right click your website --> Properties --> Directory Security --> Edit --> first checkbox) |