Showing posts with label visual. Show all posts
Showing posts with label visual. Show all posts

Wednesday, March 21, 2012

Import excel into SQL 2005 working in development but not in production

I have a simple code that uses a the file upload control to read an excel sheet and upload the data into a SQL 2005db.

I'm using Visual Web Developer and Sql's express edition to test it. It works fine when I test. However, when I push it up to the production server and try it via the any other pc it does not. The page loads fine. However, when it starts to upload it errors out.

Any reason why? I've never seen this happen.

Here's the code. Thanks in advance.

Protected Sub BtnUpload2_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles BtnUpload2.Click UploadTextDocument()End Sub Private Sub UploadTextDocument()Dim locationAs String = FileUpload1.PostedFile.FileName.ToString' Connection String to Excel WorkbookTry Dim excelConnectionStringAs String =String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0", location)' Create Connection to Excel Workbook Using connectionAs Data.OleDb.OleDbConnection =New Data.OleDb.OleDbConnection(excelConnectionString)Dim commandAs Data.OleDb.OleDbCommand =New Data.OleDb.OleDbCommand("Select BuilderID,SeriesID,OptionLevel,CommunityID,PhaseID,PlanID,ElevationID,OptionID,CurrentSalesPrice,LocalComments,Active,DateAdded,DateAvailable,DateInactive,SalesPriceEffective,SalesPriceExpires,PreviousSalesPrice,CutOffNotBefore,CutOffNotAfter FROM [Data$]", connection) connection.Open()' Create DbDataReader to Data Worksheet Using drAs Data.Common.DbDataReader = command.ExecuteReader()' SQL Server Connection StringDim connectionStringAs String = ConfigurationManager.ConnectionStrings("HbAdminMaintenance").ConnectionString' Bulk Copy to SQL Server Using bulkCopyAs SqlBulkCopy =New SqlBulkCopy(connectionString) bulkCopy.DestinationTableName ="ExcelData" bulkCopy.WriteToServer(dr)End UsingEnd Using connection.Close()End Using LBError.Text ="The spreadsheet was successfully uploaded."Catch LBError.Text ="There was an error. Check the spreadsheet for correct format."End Try End Sub

whats the exact error message ur getting?

|||

Hey Karen,

I don't get one. Debugging is off on the live application. I just get the error message at "catch".

I have a prospective client looking at it as we speak and don't want to make any changes to the web.config while they are viewing it...

|||

to catch error

use

try catch.. with and throw ex,.

one good possible reason is excel work sheet contains datatype that are not a part of datatypes of ur columns in tables. ..

there would not be any error, but the writetoserver would simply exit.. that's it..so use the old sheets u used in development server and try again.

Try printing., sheetnames and fieldcount.. in reader..

|||

Actually, I'm using the exact same sheet, same data, everything. I debugged it and still can't find any errors.

It only works from developement... I haven't tried it in a reader.

|||

How bout u try saving that file first and then transferring its contents to the database?

Regards

Karen

|||

Possible problems:

You don't have the correct version of Jet installed on the production server.

The process doesn't have read permissions at the location that the file is being written to.

try turning on remote errors in the web.config file so you can see exactly what the error is.

|||

Please provide the code topcopy the data/rows in the Excel work sheet to the sql server table.

Thanks and Regards

Ravi Shanker Maduri

Hyderabad

|||

Okay. I captured the error message. When I select the excel sheet from the folder on my desk top this message appears. The path is correct, as I said, it works fine when I do it from developent...

'C:\Documents and Settings\rednelo\Desktop\IPAddress_Mapping\test.xls'. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.


|||

The problem is this line here:

Dim locationAs String = FileUpload1.PostedFile.FileName.ToString

You are using the filename that was on the client. You need the filename of the temporary file that the server created.

|||

Hi

I want to Import The Excel Data to the sql server using T-Sql Query ,i will run somany PL-sql statements for each project i want to automate it , i want to insert the default data to a table using excel sheet to the sql server table.

Please if any one know the solution for moving the excel data to the sql server using T-Sql Statement only.

Thanks and regards

Ravishanker Maduri

|||

Motley:

You need the filename of the temporary file that the server created.

All that makes sense. How would I get to the name of the temporary file?

|||

strINVSRC = Path.GetFileName(FlInvSrc.PostedFile.FileName)

|||

Hey Karen,

I tried what you have and I'm getting this error when I put in on the server. Did you run into this?

The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data.
However, the same code in development gives me this:

The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.

So, its not finding the file. Let me recap...

Dim locationAsString

'this works in development as I said before. So I know that was finding it at least on my local machine.

location = FileUpload1.PostedFile.FileName.ToString

What you had does not appear to find the file.

location = Path.GetFileName(FileUpload1.PostedFile.FileName)

Its somewhere between the two...

|||

Take a look at this link some one gave it to me when i had the same error message

http://forums.asp.net/t/1034337.aspx

I have done it this way..

First i am getting the name of the file...

Dim strFilePath,location as string

StrFilePath = Path.GetFileName(FileUpload1.PostedFile.FileName)

and then

location = Server.Mappath("The directory where u wanna store the file" & StrFilePath.

hope this helps..

Regards

Karen

Sunday, February 19, 2012

Import & Export

Hi,
I'm using Reporting Services and MOM 2005.
How can I import existing reports to Visual Studio for design mode?I means to import all the reports and not one by one
Also, is it possible in Visual Studio to configure each report to a
different TargetFolder in the same project?
"×¢×?×?×?" wrote:
> Hi,
> I'm using Reporting Services and MOM 2005.
> How can I import existing reports to Visual Studio for design mode?|||Hi,
I try to upload my report to the reporting services using
PublishSampleReports.rss
I try to upload to a subfolder parentFolder="All SQL Report/performance"
but I ger an error message,
How can I do that ?
"×¢×?×?×?" wrote:
> I means to import all the reports and not one by one
> Also, is it possible in Visual Studio to configure each report to a
> different TargetFolder in the same project?
> "×¢×?×?×?" wrote:
> > Hi,
> >
> > I'm using Reporting Services and MOM 2005.
> > How can I import existing reports to Visual Studio for design mode?|||What error message are you getting?
--
Cheers,
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"'" <@.discussions.microsoft.com> wrote in message
news:CB82802F-3506-4BEA-973C-24D0D35813F8@.microsoft.com...
> Hi,
> I try to upload my report to the reporting services using
> PublishSampleReports.rss
> I try to upload to a subfolder parentFolder="All SQL Report/performance"
> but I ger an error message,
> How can I do that ?
> "'" wrote:
>> I means to import all the reports and not one by one
>> Also, is it possible in Visual Studio to configure each report to a
>> different TargetFolder in the same project?
>> "'" wrote:
>> > Hi,
>> >
>> > I'm using Reporting Services and MOM 2005.
>> > How can I import existing reports to Visual Studio for design mode?|||The error message:
C:\Reporting>rs -i PublishSampleReports.rss -s
http://momreporting/reportserver/
-v parentFolder="Microsoft Operations Manager Reporting/idanl"
System.Web.Services.Protocols.SoapException: The name of the item 'Microsoft
Ope
rations Manager Reporting/idanl' is not valid. The name must be less than
260 ch
aracters long, must not start with slash; other restrictions apply. Check
the do
cumentation for complete set of restrictions. -->
Microsoft.ReportingServices.D
iagnostics.Utilities.InvalidItemNameException: The name of the item
'Microsoft O
perations Manager Reporting/idanl' is not valid. The name must be less than
260
characters long, must not start with slash; other restrictions apply. Check
the
documentation for complete set of restrictions.
"Jeff A. Stucker" wrote:
> What error message are you getting?
> --
> Cheers,
> '(' Jeff A. Stucker
> \
> Business Intelligence
> www.criadvantage.com
> ---
> "'" <@.discussions.microsoft.com> wrote in message
> news:CB82802F-3506-4BEA-973C-24D0D35813F8@.microsoft.com...
> > Hi,
> > I try to upload my report to the reporting services using
> > PublishSampleReports.rss
> > I try to upload to a subfolder parentFolder="All SQL Report/performance"
> > but I ger an error message,
> > How can I do that ?
> >
> > "'" wrote:
> >
> >> I means to import all the reports and not one by one
> >>
> >> Also, is it possible in Visual Studio to configure each report to a
> >> different TargetFolder in the same project?
> >>
> >> "'" wrote:
> >>
> >> > Hi,
> >> >
> >> > I'm using Reporting Services and MOM 2005.
> >> > How can I import existing reports to Visual Studio for design mode?
>
>|||Sorry I can't help you on the RSS issue.
But I can answer the question about Visual Studio. Unfortunately, at this
time there is a one-to-one mapping between project and folder. I set up a
VS solution with multiple projects -- one for each folder I need to publish
to.
--
Cheers,
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"'" <@.discussions.microsoft.com> wrote in message
news:1DA41224-9065-4713-8169-D9F1EE29CAED@.microsoft.com...
> The error message:
> C:\Reporting>rs -i PublishSampleReports.rss -s
> http://momreporting/reportserver/
> -v parentFolder="Microsoft Operations Manager Reporting/idanl"
> System.Web.Services.Protocols.SoapException: The name of the item
> 'Microsoft
> Ope
> rations Manager Reporting/idanl' is not valid. The name must be less than
> 260 ch
> aracters long, must not start with slash; other restrictions apply. Check
> the do
> cumentation for complete set of restrictions. -->
> Microsoft.ReportingServices.D
> iagnostics.Utilities.InvalidItemNameException: The name of the item
> 'Microsoft O
> perations Manager Reporting/idanl' is not valid. The name must be less
> than
> 260
> characters long, must not start with slash; other restrictions apply.
> Check
> the
> documentation for complete set of restrictions.
> "Jeff A. Stucker" wrote:
>> What error message are you getting?
>> --
>> Cheers,
>> '(' Jeff A. Stucker
>> \
>> Business Intelligence
>> www.criadvantage.com
>> ---
>> "'" <@.discussions.microsoft.com> wrote in message
>> news:CB82802F-3506-4BEA-973C-24D0D35813F8@.microsoft.com...
>> > Hi,
>> > I try to upload my report to the reporting services using
>> > PublishSampleReports.rss
>> > I try to upload to a subfolder parentFolder="All SQL
>> > Report/performance"
>> > but I ger an error message,
>> > How can I do that ?
>> >
>> > "'" wrote:
>> >
>> >> I means to import all the reports and not one by one
>> >>
>> >> Also, is it possible in Visual Studio to configure each report to a
>> >> different TargetFolder in the same project?
>> >>
>> >> "'" wrote:
>> >>
>> >> > Hi,
>> >> >
>> >> > I'm using Reporting Services and MOM 2005.
>> >> > How can I import existing reports to Visual Studio for design mode?
>>|||Hi Jeff
I succeed to solve the problem with the path problem by run this command
without the http://momreporting/reportserver/
But while I import the report to the reporting services I get in all the
report a new text box to enter user name & password, why ?
Thanks and have a happy new years
Idan
"Jeff A. Stucker" wrote:
> Sorry I can't help you on the RSS issue.
> But I can answer the question about Visual Studio. Unfortunately, at this
> time there is a one-to-one mapping between project and folder. I set up a
> VS solution with multiple projects -- one for each folder I need to publish
> to.
> --
> Cheers,
> '(' Jeff A. Stucker
> \
> Business Intelligence
> www.criadvantage.com
> ---
> "'" <@.discussions.microsoft.com> wrote in message
> news:1DA41224-9065-4713-8169-D9F1EE29CAED@.microsoft.com...
> > The error message:
> >
> > C:\Reporting>rs -i PublishSampleReports.rss -s
> > http://momreporting/reportserver/
> > -v parentFolder="Microsoft Operations Manager Reporting/idanl"
> > System.Web.Services.Protocols.SoapException: The name of the item
> > 'Microsoft
> > Ope
> > rations Manager Reporting/idanl' is not valid. The name must be less than
> > 260 ch
> > aracters long, must not start with slash; other restrictions apply. Check
> > the do
> > cumentation for complete set of restrictions. -->
> > Microsoft.ReportingServices.D
> > iagnostics.Utilities.InvalidItemNameException: The name of the item
> > 'Microsoft O
> > perations Manager Reporting/idanl' is not valid. The name must be less
> > than
> > 260
> > characters long, must not start with slash; other restrictions apply.
> > Check
> > the
> > documentation for complete set of restrictions.
> >
> > "Jeff A. Stucker" wrote:
> >
> >> What error message are you getting?
> >>
> >> --
> >> Cheers,
> >>
> >> '(' Jeff A. Stucker
> >> \
> >>
> >> Business Intelligence
> >> www.criadvantage.com
> >> ---
> >> "'" <@.discussions.microsoft.com> wrote in message
> >> news:CB82802F-3506-4BEA-973C-24D0D35813F8@.microsoft.com...
> >> > Hi,
> >> > I try to upload my report to the reporting services using
> >> > PublishSampleReports.rss
> >> > I try to upload to a subfolder parentFolder="All SQL
> >> > Report/performance"
> >> > but I ger an error message,
> >> > How can I do that ?
> >> >
> >> > "'" wrote:
> >> >
> >> >> I means to import all the reports and not one by one
> >> >>
> >> >> Also, is it possible in Visual Studio to configure each report to a
> >> >> different TargetFolder in the same project?
> >> >>
> >> >> "'" wrote:
> >> >>
> >> >> > Hi,
> >> >> >
> >> >> > I'm using Reporting Services and MOM 2005.
> >> >> > How can I import existing reports to Visual Studio for design mode?
> >>
> >>
> >>
>
>|||Check the report permissions in Report Manager (http://<server>/Reports)
--
Cheers,
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"'" <@.discussions.microsoft.com> wrote in message
news:5DE0A914-146E-46B9-AF6A-F77127BE5A47@.microsoft.com...
> Hi Jeff
> I succeed to solve the problem with the path problem by run this command
> without the http://momreporting/reportserver/
> But while I import the report to the reporting services I get in all the
> report a new text box to enter user name & password, why ?
> Thanks and have a happy new years
> Idan
>
> "Jeff A. Stucker" wrote:
>> Sorry I can't help you on the RSS issue.
>> But I can answer the question about Visual Studio. Unfortunately, at
>> this
>> time there is a one-to-one mapping between project and folder. I set up
>> a
>> VS solution with multiple projects -- one for each folder I need to
>> publish
>> to.
>> --
>> Cheers,
>> '(' Jeff A. Stucker
>> \
>> Business Intelligence
>> www.criadvantage.com
>> ---
>> "'" <@.discussions.microsoft.com> wrote in message
>> news:1DA41224-9065-4713-8169-D9F1EE29CAED@.microsoft.com...
>> > The error message:
>> >
>> > C:\Reporting>rs -i PublishSampleReports.rss -s
>> > http://momreporting/reportserver/
>> > -v parentFolder="Microsoft Operations Manager Reporting/idanl"
>> > System.Web.Services.Protocols.SoapException: The name of the item
>> > 'Microsoft
>> > Ope
>> > rations Manager Reporting/idanl' is not valid. The name must be less
>> > than
>> > 260 ch
>> > aracters long, must not start with slash; other restrictions apply.
>> > Check
>> > the do
>> > cumentation for complete set of restrictions. -->
>> > Microsoft.ReportingServices.D
>> > iagnostics.Utilities.InvalidItemNameException: The name of the item
>> > 'Microsoft O
>> > perations Manager Reporting/idanl' is not valid. The name must be less
>> > than
>> > 260
>> > characters long, must not start with slash; other restrictions apply.
>> > Check
>> > the
>> > documentation for complete set of restrictions.
>> >
>> > "Jeff A. Stucker" wrote:
>> >
>> >> What error message are you getting?
>> >>
>> >> --
>> >> Cheers,
>> >>
>> >> '(' Jeff A. Stucker
>> >> \
>> >>
>> >> Business Intelligence
>> >> www.criadvantage.com
>> >> ---
>> >> "'" <@.discussions.microsoft.com> wrote in message
>> >> news:CB82802F-3506-4BEA-973C-24D0D35813F8@.microsoft.com...
>> >> > Hi,
>> >> > I try to upload my report to the reporting services using
>> >> > PublishSampleReports.rss
>> >> > I try to upload to a subfolder parentFolder="All SQL
>> >> > Report/performance"
>> >> > but I ger an error message,
>> >> > How can I do that ?
>> >> >
>> >> > "'" wrote:
>> >> >
>> >> >> I means to import all the reports and not one by one
>> >> >>
>> >> >> Also, is it possible in Visual Studio to configure each report to a
>> >> >> different TargetFolder in the same project?
>> >> >>
>> >> >> "'" wrote:
>> >> >>
>> >> >> > Hi,
>> >> >> >
>> >> >> > I'm using Reporting Services and MOM 2005.
>> >> >> > How can I import existing reports to Visual Studio for design
>> >> >> > mode?
>> >>
>> >>
>> >>
>>|||Thanks jeff
I know I can change the report permission under each report,
but if I have a lot of report I need to change it each one, Why the import
process cause this ?
"Jeff A. Stucker" wrote:
> Check the report permissions in Report Manager (http://<server>/Reports)
> --
> Cheers,
> '(' Jeff A. Stucker
> \
> Business Intelligence
> www.criadvantage.com
> ---
> "'" <@.discussions.microsoft.com> wrote in message
> news:5DE0A914-146E-46B9-AF6A-F77127BE5A47@.microsoft.com...
> > Hi Jeff
> > I succeed to solve the problem with the path problem by run this command
> > without the http://momreporting/reportserver/
> >
> > But while I import the report to the reporting services I get in all the
> > report a new text box to enter user name & password, why ?
> >
> > Thanks and have a happy new years
> >
> > Idan
> >
> >
> > "Jeff A. Stucker" wrote:
> >
> >> Sorry I can't help you on the RSS issue.
> >>
> >> But I can answer the question about Visual Studio. Unfortunately, at
> >> this
> >> time there is a one-to-one mapping between project and folder. I set up
> >> a
> >> VS solution with multiple projects -- one for each folder I need to
> >> publish
> >> to.
> >>
> >> --
> >> Cheers,
> >>
> >> '(' Jeff A. Stucker
> >> \
> >>
> >> Business Intelligence
> >> www.criadvantage.com
> >> ---
> >> "'" <@.discussions.microsoft.com> wrote in message
> >> news:1DA41224-9065-4713-8169-D9F1EE29CAED@.microsoft.com...
> >> > The error message:
> >> >
> >> > C:\Reporting>rs -i PublishSampleReports.rss -s
> >> > http://momreporting/reportserver/
> >> > -v parentFolder="Microsoft Operations Manager Reporting/idanl"
> >> > System.Web.Services.Protocols.SoapException: The name of the item
> >> > 'Microsoft
> >> > Ope
> >> > rations Manager Reporting/idanl' is not valid. The name must be less
> >> > than
> >> > 260 ch
> >> > aracters long, must not start with slash; other restrictions apply.
> >> > Check
> >> > the do
> >> > cumentation for complete set of restrictions. -->
> >> > Microsoft.ReportingServices.D
> >> > iagnostics.Utilities.InvalidItemNameException: The name of the item
> >> > 'Microsoft O
> >> > perations Manager Reporting/idanl' is not valid. The name must be less
> >> > than
> >> > 260
> >> > characters long, must not start with slash; other restrictions apply.
> >> > Check
> >> > the
> >> > documentation for complete set of restrictions.
> >> >
> >> > "Jeff A. Stucker" wrote:
> >> >
> >> >> What error message are you getting?
> >> >>
> >> >> --
> >> >> Cheers,
> >> >>
> >> >> '(' Jeff A. Stucker
> >> >> \
> >> >>
> >> >> Business Intelligence
> >> >> www.criadvantage.com
> >> >> ---
> >> >> "'" <@.discussions.microsoft.com> wrote in message
> >> >> news:CB82802F-3506-4BEA-973C-24D0D35813F8@.microsoft.com...
> >> >> > Hi,
> >> >> > I try to upload my report to the reporting services using
> >> >> > PublishSampleReports.rss
> >> >> > I try to upload to a subfolder parentFolder="All SQL
> >> >> > Report/performance"
> >> >> > but I ger an error message,
> >> >> > How can I do that ?
> >> >> >
> >> >> > "'" wrote:
> >> >> >
> >> >> >> I means to import all the reports and not one by one
> >> >> >>
> >> >> >> Also, is it possible in Visual Studio to configure each report to a
> >> >> >> different TargetFolder in the same project?
> >> >> >>
> >> >> >> "'" wrote:
> >> >> >>
> >> >> >> > Hi,
> >> >> >> >
> >> >> >> > I'm using Reporting Services and MOM 2005.
> >> >> >> > How can I import existing reports to Visual Studio for design
> >> >> >> > mode?
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>