Friday, March 30, 2012

Saving User's Report Parameters

(Reposting, reworded)
I am writing a C# Web application with a web form that displays a report
using URL access method. The URL displays the report for the user, and then
they can pick their parameters and run the report.
I want to know: how can I display the report to the user the next time with
all of the same parameters that they chose? I don't want a snapshot, I want
to refresh the data for the same parameters the user chose.
Do I need to use form post method? or SOAP? Or is there a way to do this
with URL access.
The problem is that when the user changes the value of a parameter, the URL
does not change, so I cannot access that information from my C# Web
application.
MalikFor the level of control you want you need to use web services (soap). You
can definitely get the information you want with that. The URL access will
not provide what you want.
Bruce L-C
"Abdul Malik Said" <diplacusis@.hotmNOSPAMail.com> wrote in message
news:%23OdayAThEHA.3612@.TK2MSFTNGP12.phx.gbl...
> (Reposting, reworded)
> I am writing a C# Web application with a web form that displays a report
> using URL access method. The URL displays the report for the user, and
then
> they can pick their parameters and run the report.
> I want to know: how can I display the report to the user the next time
with
> all of the same parameters that they chose? I don't want a snapshot, I
want
> to refresh the data for the same parameters the user chose.
> Do I need to use form post method? or SOAP? Or is there a way to do this
> with URL access.
> The problem is that when the user changes the value of a parameter, the
URL
> does not change, so I cannot access that information from my C# Web
> application.
> Malik
>|||While there's no easy way to do this, it is possible by making the parameter default populate their
values from a database table which looks up the last parameter values used by that user (or a
default if no row exists). You would then also need a set of queries which stored the current
parameter values in the database when the report is run.
--
Thanks.
Donovan R. Smith
Software Test Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
"Bruce Loehle-Conger" <bruce_lcNOSPAM@.hotmail.com> wrote in message
news:e7sShOThEHA.3148@.TK2MSFTNGP10.phx.gbl...
> For the level of control you want you need to use web services (soap). You
> can definitely get the information you want with that. The URL access will
> not provide what you want.
> Bruce L-C
> "Abdul Malik Said" <diplacusis@.hotmNOSPAMail.com> wrote in message
> news:%23OdayAThEHA.3612@.TK2MSFTNGP12.phx.gbl...
> > (Reposting, reworded)
> >
> > I am writing a C# Web application with a web form that displays a report
> > using URL access method. The URL displays the report for the user, and
> then
> > they can pick their parameters and run the report.
> >
> > I want to know: how can I display the report to the user the next time
> with
> > all of the same parameters that they chose? I don't want a snapshot, I
> want
> > to refresh the data for the same parameters the user chose.
> >
> > Do I need to use form post method? or SOAP? Or is there a way to do this
> > with URL access.
> >
> > The problem is that when the user changes the value of a parameter, the
> URL
> > does not change, so I cannot access that information from my C# Web
> > application.
> >
> > Malik
> >
> >
>|||Thank you very much for both of your responses.
I did assume that I would have to store parameter values in my own database
table to be able to save report parameters, so that is not really a problem.
In fact, my application already has a table to store parameters, I just have
to define a new parameter type, then put parameter names and values in the
existing table.
But I wouldn't get anywhere without SOAP. My gap in knowledge here was how
to do SOAP integration. I am now hurriedly learning how to do this, but it
doesn't seem overly complicated. It seems like there is a reporting services
object model, and I can somehow get the current parameter values from an
object, so I am content to keep hitting the books until the solution comes
together.
Thanks again for pointing me in the right direction.
Malik
"Donovan R. Smith [MSFT]" <donovans@.online.microsoft.com> wrote in message
news:eKhQrFUhEHA.2624@.TK2MSFTNGP12.phx.gbl...
> While there's no easy way to do this, it is possible by making the
parameter default populate their
> values from a database table which looks up the last parameter values used
by that user (or a
> default if no row exists). You would then also need a set of queries
which stored the current
> parameter values in the database when the report is run.
> --
> Thanks.
> Donovan R. Smith
> Software Test Lead
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> "Bruce Loehle-Conger" <bruce_lcNOSPAM@.hotmail.com> wrote in message
> news:e7sShOThEHA.3148@.TK2MSFTNGP10.phx.gbl...
> > For the level of control you want you need to use web services (soap).
You
> > can definitely get the information you want with that. The URL access
will
> > not provide what you want.
> >
> > Bruce L-C
> >
> > "Abdul Malik Said" <diplacusis@.hotmNOSPAMail.com> wrote in message
> > news:%23OdayAThEHA.3612@.TK2MSFTNGP12.phx.gbl...
> > > (Reposting, reworded)
> > >
> > > I am writing a C# Web application with a web form that displays a
report
> > > using URL access method. The URL displays the report for the user, and
> > then
> > > they can pick their parameters and run the report.
> > >
> > > I want to know: how can I display the report to the user the next time
> > with
> > > all of the same parameters that they chose? I don't want a snapshot, I
> > want
> > > to refresh the data for the same parameters the user chose.
> > >
> > > Do I need to use form post method? or SOAP? Or is there a way to do
this
> > > with URL access.
> > >
> > > The problem is that when the user changes the value of a parameter,
the
> > URL
> > > does not change, so I cannot access that information from my C# Web
> > > application.
> > >
> > > Malik
> > >
> > >
> >
> >
>sql

Saving uploaded picture filepath to sql database

I am trying to save an uploaded picture filepath to a sql database record. The record that the filepath will be saved to will be the record determined by the logged in userid. I get an error stating Object not set to an instance of an object. This is my code for when the upload button is hit

ProtectedSub uploadbutton_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles uploadbutton.Click

If UploadTest.HasFile =FalseThen

' No file uploaded!

UploadDetails.Text ="Please first select a file to upload..."

Else

' Display the uploaded file's details

UploadDetails.Text =String.Format( _

"Uploaded file: {0}<br />" & _

"File size (in bytes): {1:N0}<br />" & _"Content-type: {2}", _

UploadTest.FileName, _

UploadTest.FileBytes.Length, _

UploadTest.PostedFile.ContentType)

' Save the file

Dim filePathAsString = Server.MapPath("~/ProfilePictures/" & UploadTest.FileName)

UploadTest.SaveAs(filePath)

Dim datasources1AsNew SqlDataSourcedatasources1.ConnectionString = ConfigurationManager.ConnectionStrings("aspnetdb_connection").ToString()

datasources1.UpdateCommandType = SqlDataSourceCommandType.Text

Dim myUserIDAsString = Membership.GetUser().ProviderUserKey.ToString

datasources1.UpdateParameters("userid").DefaultValue = myUserID

datasources1.UpdateCommand ="UPDATE into profile_details (pic) VALUES (@.filepath) WHERE ([UserId] = @.UserId)"

EndIf

EndSub

Any ideas on what i need to do to fix this?

i save image path into my database too

1: i take the file name and i create a dirrectory with the name of loged in user

string fileName = FileUpload1.FileName.ToString(); //i don't know if is FileName() or FileName.ToString()...

string userName = Profile.UserName;

string uploadFolderPath ="~/upload/"; // the folder where you save uploads

string filePath =HttpContext.Current.Server.MapPath(uploadFolderPath);

Directory.CreateDirectory(filePath +"\\" + userName);

2: i save the picture

FileUpload1.SaveAs("F:\\Documents and Settings\\Administrator\\Desktop\\WebSite2\\upload\\" + userName +"\\" + fileName);

3: i save the filepath into a hiddenField

HiddenField1.Value = userName +"\\" + fileName; // would be like "user1\picture.jpg"

4: i insert the HiddenField1 Value into my database

this is what i did and i am pleased...hope i helped you

|||

The problem I am having is the actual code to imput the string into the database. It seems if i use the hiddenfield way your talking about their has to be another step to actually input it.

|||

i don't understand very clear what you mean, but i use a stored procedure to insert the filepath into database like this one

CREATE PROCEDURE InsertPicture@.Image1varchar(200)ASINSERT INTO Pictures (Image1)VALUES (@.Image1)

you can use an update procedure instead of iseart if you want to change the filepath for a specific picture with PictureID = x

and in the code behind you will have something like this

SqlConnection conn =new SqlConnection(ConnectionString);// wite your conn string in bracketsSqlCommand command =new SqlCommand("InsertPicture", conn);command.CommandType = CommandType.StoredProcedure;SqlParameter Image1_param =new SqlParameter();Image1_param.ParameterName ="@.Image1";Image1_param.SqlDbType = SqlDbType.VarChar;Image1_param.Value = HiddenField1.Value.ToString();command.Parameters.Add(Image1_param);conn.Open();SqlDataReader reader = command.ExecuteNonQuery();reader.Close();command.Connection.Close();conn.Close();
|||

in your example what column in the database are you saving the imagefile path to? Image1 right?

|||

yes, i have many columns like PictureID, Name, Description and so on, but in Image1 i store the filepath

Saving updated row

Is there a way to save a record(s) prior to modifying values in it via trigger? If not, what options do I have to maintain something like a snapshot of the record(s) besides backups?
BTW, I use SQL 7.
ThanksRefer to Using the inserted and deleted Tables under books online.

Saving to SQL

I am currently migrating my application from Access to SQL. It looks like it's working good but one thing I cannot understand is why when I have created a varchar(40) field and after I insert a field that is less then 40 characters long, the rest of the string is filled with the leading spaces. I have also create an nchar(40) that did not solve it ether. For example: the text is "Hello World". The text is 11 characters long but the data saved to the table is: "Hello Wolrd" + 29 spaces.

Am I doing something wrong?


Thanks for your help in advance.

Use nvarchar(40) instead. The nchar(40) is for a fixed length column.

|||

I have used nvarchar(40) and varchar(40) and both save with the trailing spaces. I have changed one of the tables and it seems it took effect but then the other table still does the same thing. I wonder what I did to get it working. I don't remember the steps I took. Is there something else besides changing the datafields?

|||

You can update your varchar(nvarchar) column with TRIM functions to remove trailing spaces from both ends(just in case).

UPDATE yourTableSET colVarChar40=LTRIM(RTRIM(colChar40))

|||

I am actually Inserting the new value not updating. How can I accomplish this?

|||

please show your insert code.

|||

the update is for after you have done all your inserting just update it.... or in your sproc before you insert the value do the trim

Saving to a Web Folder i.e WSS

Is it possible for reporting services to save a report to a web folder or
more specifically WSS/SharePoint when you define a subscription? We save all
our reports on a WSS site and we would like to remove this as a manual step.
Oh and is it possible to dynamically change the path based on the month and
year, for example create a new folder for the month of december to put all
the reports for that month in.
thanks for any help!This is not currently supported. You would need to write your own delivery
extension to do this. Delivery extensions are fairly easy to write, you
should look at the Printer Delivery Sample for how to get started.
--
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.
"anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
news:EA07C8FB-287E-48B6-94E5-ABA172763330@.microsoft.com...
> Is it possible for reporting services to save a report to a web folder or
> more specifically WSS/SharePoint when you define a subscription? We save
> all
> our reports on a WSS site and we would like to remove this as a manual
> step.
> Oh and is it possible to dynamically change the path based on the month
> and
> year, for example create a new folder for the month of december to put all
> the reports for that month in.
> thanks for any help!|||Where would I find the printer delivery sample?
Thanks for the help!!
"Daniel Reib [MSFT]" wrote:
> This is not currently supported. You would need to write your own delivery
> extension to do this. Delivery extensions are fairly easy to write, you
> should look at the Printer Delivery Sample for how to get started.
> --
> -Daniel
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> news:EA07C8FB-287E-48B6-94E5-ABA172763330@.microsoft.com...
> > Is it possible for reporting services to save a report to a web folder or
> > more specifically WSS/SharePoint when you define a subscription? We save
> > all
> > our reports on a WSS site and we would like to remove this as a manual
> > step.
> >
> > Oh and is it possible to dynamically change the path based on the month
> > and
> > year, for example create a new folder for the month of december to put all
> > the reports for that month in.
> >
> > thanks for any help!
>
>|||That depends on the version of RS you are using. Both are included in setup.
You can find more info here:
RS 2005:
http://msdn2.microsoft.com/library/ms160954(en-us,SQL.90).aspx
RS 2000:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rsamples/htm/rss_sampleapps_v1_3t69.asp
--
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.
"anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
news:92B40DFD-55CB-4821-9B75-BE35E8C577E5@.microsoft.com...
> Where would I find the printer delivery sample?
> Thanks for the help!!
> "Daniel Reib [MSFT]" wrote:
>> This is not currently supported. You would need to write your own
>> delivery
>> extension to do this. Delivery extensions are fairly easy to write, you
>> should look at the Printer Delivery Sample for how to get started.
>> --
>> -Daniel
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
>> news:EA07C8FB-287E-48B6-94E5-ABA172763330@.microsoft.com...
>> > Is it possible for reporting services to save a report to a web folder
>> > or
>> > more specifically WSS/SharePoint when you define a subscription? We
>> > save
>> > all
>> > our reports on a WSS site and we would like to remove this as a manual
>> > step.
>> >
>> > Oh and is it possible to dynamically change the path based on the month
>> > and
>> > year, for example create a new folder for the month of december to put
>> > all
>> > the reports for that month in.
>> >
>> > thanks for any help!
>>

saving time in snapshot?

We are using SQL 2K with sp4 and using push replication.
if I set up the push replication for the very first time, is there a way to
save the time for the initial snapshot generation of all tables by having the
subcriber database popuated with tables using backup and restore method from
the publishing dataabase? Then, can I make replication think that two
databases are in syn already (which it is) and start replicate changes from
this point on via the log reader?
wingman
Yes - this is referred to as a nosync initialization. Please see this
article for more info:
http://www.replicationanswers.com/No...alizations.asp
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
sql

Saving Time in 12 hour format

Hi,
By default in SQL Server, when I store a time in an Datetime field, it
stores in 24 hour format. but I want to store in 12 hours format with AM/PM
also being stored.
Can anyone help me in this.
Thanks & Regards
Sudhakara.T.P.Its is not important how the data is stored in the database. all that
metters is how u retreive the data.
if u want to retrive with AM and PM format: u can use
CONVERT(varchar(20), getdate(), 100)
please let me know if u have any questions
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"Sudhakara.T.P." wrote:

> Hi,
> By default in SQL Server, when I store a time in an Datetime field, it
> stores in 24 hour format. but I want to store in 12 hours format with AM/P
M
> also being stored.
> Can anyone help me in this.
> Thanks & Regards
> Sudhakara.T.P.|||Hi,
I am very much aware of the fact of retreiving the records in the format
that I want, but I am very much interested in storing the time data in 12
hour format itself as this is one of my prime requirement.
"Chandra" wrote:
> Its is not important how the data is stored in the database. all that
> metters is how u retreive the data.
> if u want to retrive with AM and PM format: u can use
> CONVERT(varchar(20), getdate(), 100)
> please let me know if u have any questions
>
> --
> best Regards,
> Chandra
> http://chanduas.blogspot.com/
> http://www.SQLResource.com/
> ---
>
> "Sudhakara.T.P." wrote:
>|||SQL Server does not store datetime values in any user specified format,
but in an internal format.
So showing the AM/PM is basically a formatting issue.
You can use the CONVERT function to do the same.
Have a look at
http://www.karaszi.com/sqlserver/info_datetime.asp
Roji. P. Thomas
Net Asset Management
http://toponewithties.blogspot.com
"Sudhakara.T.P." <SudhakaraTP@.discussions.microsoft.com> wrote in message
news:BB0D056C-CA8C-4D59-9B97-EDB5B3CBE88E@.microsoft.com...
> Hi,
> By default in SQL Server, when I store a time in an Datetime field, it
> stores in 24 hour format. but I want to store in 12 hours format with
> AM/PM
> also being stored.
> Can anyone help me in this.
> Thanks & Regards
> Sudhakara.T.P.|||then create a varchar field for this instead of datetime field. hope this
can solve the purpose.
may i know the prime reason behind storing as that format. probably i can
give u a suggestion
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"Sudhakara.T.P." wrote:
> Hi,
> I am very much aware of the fact of retreiving the records in the format
> that I want, but I am very much interested in storing the time data in 12
> hour format itself as this is one of my prime requirement.
> "Chandra" wrote:
>|||Hi Chandra,
thanks for the reply.
Well for one of the project that we are developing for the client, it is his
prime requirement to see the datetime record saved in the database in 12 hou
r
format as the db administrator is the client himself and he needs to open th
e
database and check the records frequently for some of his purposes[which he
has not revealed the reason].
I am freelance programmer and this is his first requirement/condition in the
project.
Regards
Sudhakara.T.P.|||then for this purpose, i prefer using a view and those who want to check can
use a view instead of referrig directly to a table
pleas let me know if u have any questions
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"Sudhakara.T.P." wrote:

> Hi Chandra,
> thanks for the reply.
> Well for one of the project that we are developing for the client, it is h
is
> prime requirement to see the datetime record saved in the database in 12 h
our
> format as the db administrator is the client himself and he needs to open
the
> database and check the records frequently for some of his purposes[which h
e
> has not revealed the reason].
> I am freelance programmer and this is his first requirement/condition in t
he
> project.
> Regards
> Sudhakara.T.P.|||>> By default in SQL Server, when I store a time in an Datetime field [sic], it s
tores in 24 hour format. but I want to store in 12 hours format with AM/PM a
lso being stored. <<
Take your hands off the keyboard. Step away from the database. You
are dangerously ignorant.
Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files. One of the *many* differences in
a field and column is that a column has an abstract datatype and
meaning in and of itself. A field gets its meaning from the program
that reads it. This kind of question is the result of not knowing
these differences.
How a column is displayed in done in the host program and has nothing
WHATSOEVER to do with the internal format in the RDBMS. In the case of
T-SQL, it is a "floating point number" that counts clock ticks. To
display it as a string, you use CONVERT() and a format parameter.
Now, if you are a good SQL programmer who respects ISO standards you
use ISO-8601 formats only to avoid data exchange problems, ambigous
dates and other problems so you would never have AM/PM times in your
front end.