Monday, March 12, 2012
How to suppress Report Header
The data comes from 3 tables (Vehicles, Servicing & ServiceType). With the following layouts:
Vehicles:
VehicleID
Description
Servicing:
ServiceType
ServiceDate
VehicleID
ServiceType:
ServiceType
Duration (How often the servicing is to be done)
The report is to show what Servicing is coming due based on how often the servicetype is performed. The report is grouped by vehicle and service type with the records printed on the Service Type (Group 2) footer. There is a running total field (MaxDate) that is used to determine when the particular service type is due next for the given vehicle since the same service type can be performed multiple times on the same vehicle.
The question is how do I suppress the header when no records are printed?
I have tried doing a Suppress formula checking for IsNull or Count>0 for ServiceType but the count is always greater than the number of fields that are actually printed.
Thanks for any help you can provide.I rarely use the report header section, unless I want to print the report to confirm it has null data (ie print an empty report as a way of confirming something has no data).
I generally use the Page Header to contain logos, titles etc to print at top of each page.
If there's no data, the page header etc won't print....
Dave|||Thanks for the response but I wouldnt want the header to appear at the top of every page. Is there a way to have it only print once?
The report would look something like:
SERVICING
Service Type Due Date
Brake Adjustment Aug 7 2004
Inspection Aug 9 2004
The Servicing title and the column headers are the items I currently have in the Report header.|||Put fields in the report header which u want to print only once. And put those fields in the page header which u want to print on the top of every page.
And to suppress in case of no record, u can put a formula in the format section of the report like
Suppress IF {...}|||I have tried putting a suppress formula in the Report Header of IsNull(ServiceType.Description) or Count(ServiceType.Description) = 0 but it didnt work. The problem was the Count was greater than 0 but they are all being suppressed by the formula in the Group 2 Footer.
Is there a way to calculate the number actually being displayed? Also, when does Crystal compute whether the Report Header should display? Does it do this before or after the details are printed?|||if you want to suppress on the basis of count then u can put formula on any of your record coming from DB, checking for 0.
I dont know this ServiceType.Description as i worked in CR-7 n didnt see this thing there.
Also while open the formatting Tab of format header dection and there you can find to put formula on suppressing the section.|||That is exactly what I did. The problem seems to be that the count is always zero in the Report Header section. If I display the count as it prints the records and in the Report Footer it shows the accurate count.
The question is how do I base the suppression on the number of records displayed?
Friday, March 9, 2012
How to Sum last three groups
How do I create a formula that displays the sum for the last three months?
Mon Sum 3monthSum
Jan 20.00 20.00 //(Jan)
Feb 10.00 30.00 //(Jan - Feb)
Mar 40.00 70.00 //(Jan - Mar)
Apr 30.00 80.00 //(Feb - Apr)
May 15.00 85.00 //(Mar - May)
Thanks,Do you want to find summation of sum of each month?
Make use of Running total feature
Wednesday, March 7, 2012
How to store/retrieve image/file in sql db
I want to employee details in one table along with his photograph and resume
.
How can I achieve this? I'm fresher and I don't have any basic idea about th
is.
Can somebody lead me to a worked out example.
If appropriate how to use WRITETEXT/READTEXT to achieve this task?
thanks in advance.
M.L.SrinivasYou can start here:
http://support.microsoft.com/kb/308042
or
You can use TextCopy.exe in the \bin folder.
-- OJ: TEXTCOPY example
-- Loading files into db &
-- exporting files out to folder
--
--TEXTCOPY IN
--
--create tb to hold data
create table tmp(fname varchar(100),img image default '0x0')
go
declare @.sql varchar(255),
@.fname varchar(100),
@.path varchar(50),
@.user sysname,
@.pass sysname
set @.user='myuser'
set @.pass='mypass'
--specify desired folder
set @.path='c:\winnt'
set @.sql='dir ' + @.path + '*.bmp /c /b'
--insert filenames into tb
insert tmp(fname)
exec master..xp_cmdshell @.sql
--loop through and insert file contents into tb
declare cc cursor
for select fname from tmp
open cc
fetch next from cc into @.fname
while @.@.fetch_status=0
begin
set @.sql='textcopy /s"'+@.@.servername+'" /u"'+@.user+'" /p"'+@.pass+'"
/d"'+db_name()+'" /t"tmp" /c"img" /w"where fname=''' + @.fname + '''"'
set @.sql=@.sql + ' /f"' + @.path + @.fname + '" /i' + ' /z'
print @.sql
exec master..xp_cmdshell @.sql ,no_output
fetch next from cc into @.fname
end
close cc
deallocate cc
go
select * from tmp
go
--
--TEXTCOPY OUT
--
declare @.sql varchar(255),
@.fname varchar(100),
@.path varchar(50),
@.user sysname,
@.pass sysname
set @.user='myuser'
set @.pass='mypass,'
--specify desired output folder
set @.path='c:\tmp'
set @.sql='md ' + @.path
--create output folder
exec master..xp_cmdshell @.sql
--loop through and insert file contents into tb
declare cc cursor
for select fname from tmp
open cc
fetch next from cc into @.fname
while @.@.fetch_status=0
begin
set @.sql='textcopy /s"'+@.@.servername+'" /u"'+@.user+'" /p"'+@.pass+'"
/d"'+db_name()+'" /t"tmp" /c"img" /w"where fname=''' + @.fname + '''"'
set @.sql=@.sql + ' /f"' + @.path + @.fname + '" /o' + ' /z'
print @.sql
exec master..xp_cmdshell @.sql ,no_output
fetch next from cc into @.fname
end
close cc
deallocate cc
set @.sql='dir ' + @.path + '*.bmp /c /b'
exec master..xp_cmdshell @.sql
go
drop table tmp
go
-oj
"M.L.Srinivas" <mlsrinivas@.indiatimes.com> wrote in message
news:9fa72100.0502102147.1a18787@.posting.google.com...
> Hi Guys,
> I want to employee details in one table along with his photograph and
> resume.
> How can I achieve this? I'm fresher and I don't have any basic idea about
> this.
> Can somebody lead me to a worked out example.
> If appropriate how to use WRITETEXT/READTEXT to achieve this task?
> thanks in advance.
> M.L.Srinivas|||I have gone threw this tutorial. But when I retrieve the image from the DB.
The image is only 1B, and I cannot open it. The filename is correct.
Whats wrong here?
-- Kenneth
"oj" wrote:
> You can start here:
> http://support.microsoft.com/kb/308042
> or
> You can use TextCopy.exe in the \bin folder.
> -- OJ: TEXTCOPY example
> -- Loading files into db &
> -- exporting files out to folder
> --
> --
> --TEXTCOPY IN
> --
> --create tb to hold data
> create table tmp(fname varchar(100),img image default '0x0')
> go
> declare @.sql varchar(255),
> @.fname varchar(100),
> @.path varchar(50),
> @.user sysname,
> @.pass sysname
> set @.user='myuser'
> set @.pass='mypass'
> --specify desired folder
> set @.path='c:\winnt'
> set @.sql='dir ' + @.path + '*.bmp /c /b'
> --insert filenames into tb
> insert tmp(fname)
> exec master..xp_cmdshell @.sql
> --loop through and insert file contents into tb
> declare cc cursor
> for select fname from tmp
> open cc
> fetch next from cc into @.fname
> while @.@.fetch_status=0
> begin
> set @.sql='textcopy /s"'+@.@.servername+'" /u"'+@.user+'" /p"'+@.pass+'"
> /d"'+db_name()+'" /t"tmp" /c"img" /w"where fname=''' + @.fname + '''"'
> set @.sql=@.sql + ' /f"' + @.path + @.fname + '" /i' + ' /z'
> print @.sql
> exec master..xp_cmdshell @.sql ,no_output
> fetch next from cc into @.fname
> end
> close cc
> deallocate cc
> go
> select * from tmp
> go
> --
> --TEXTCOPY OUT
> --
> declare @.sql varchar(255),
> @.fname varchar(100),
> @.path varchar(50),
> @.user sysname,
> @.pass sysname
> set @.user='myuser'
> set @.pass='mypass,'
> --specify desired output folder
> set @.path='c:\tmp'
> set @.sql='md ' + @.path
> --create output folder
> exec master..xp_cmdshell @.sql
> --loop through and insert file contents into tb
> declare cc cursor
> for select fname from tmp
> open cc
> fetch next from cc into @.fname
> while @.@.fetch_status=0
> begin
> set @.sql='textcopy /s"'+@.@.servername+'" /u"'+@.user+'" /p"'+@.pass+'"
> /d"'+db_name()+'" /t"tmp" /c"img" /w"where fname=''' + @.fname + '''"'
> set @.sql=@.sql + ' /f"' + @.path + @.fname + '" /o' + ' /z'
> print @.sql
> exec master..xp_cmdshell @.sql ,no_output
> fetch next from cc into @.fname
> end
> close cc
> deallocate cc
> set @.sql='dir ' + @.path + '*.bmp /c /b'
> exec master..xp_cmdshell @.sql
> go
> drop table tmp
> go
>
> --
> -oj
>
> "M.L.Srinivas" <mlsrinivas@.indiatimes.com> wrote in message
> news:9fa72100.0502102147.1a18787@.posting.google.com...
>
>
Friday, February 24, 2012
how to store encrypted data in sql database
I have a login page in asp.net with the details being stored in the database. In the table at present i am storing the password in plain text field.
Is there any possible for me to store the data in any encrypted format or some format so that no one will be able to view the password.
And while returning back to the webpage i want them in the plain text . . . !
Is there any possibility for this
kindly help at the earliest
thanks in advance
sasidar::Is there any possibility for this
Sure. Just encrypt the data before writing it into the server, decrypt it after reading it.
note, though, that what you do here is NOT safe. Why do you ever want to decrypt the password? Use a hash and compare the hashed values.|||The best solution is to use a one way hash created in ASP.NET code, and then whenever you want to check the entered password you create a hashed copy of the password entered, and then compare it to the hash stored in the database.
private string CreatePasswordHash(string pwd,string salt)
{
string saltAndPwd=string.Concat(pwd,salt);
string hashedPwd=FormsAuthentication.HashPasswordForStoringInConfigFile(saltAndPwd,"SHA1");
return hashedPwd;
}
The salt string is just a string used to ensure that each password when encrypted will be unique (so if two people have a password of "password" the hashes will not be the same.
This way, really no one, not even you as the administrator of teh system, will be able to read the password (this is a good thing). You can of course create a method to reset the password.|||Steve Wyncoop of theSQL Server Worldwide User's Group is ga-ga overXP_CRYPT. I've not used the product, but it looks like it simplifies saving encrypted data to SQL Server.
Don|||Thanks for those who replied me,
But there is one more doubt for me. If i am using the hashing technique then we cannot reveal the password in the plain text format. Suppose if there is a situation where i require the password to known how to get back the plain text format. ?
Through my readings i came to conclusion that it cannot be done. Is it So ? In that case is there any other technique so that i can encrypt the password and then decrypt the password whenever required
Awaiting for the solutions :
Thanks in advance
Sasidar|||You should work out a way that you never need to get to the decrypted password. People often use the same password for lots of things. If a user uses their one password on your site, it is better that even you never be able to get to that password.
In systems I write, we have a system in place where a password can be reset, but we have no way to reverse the one way hash. This way, even if the database is compromised, user's passwords will not be exposed. Your users will appreciate it.|||Thanks for ur reply ,
but still i have a doubt , say suppose my client or user forget his pasword , then what should i do so that i can change the password . If i am going to change contecnts directly into the database then the plain text will be changed and i hope that will not be fine. Is there any solution for this
Awaiting for the solution
Thanks
Bye
Sasidar|||The way tou handle that is to create an administrative page that allows you to reset the password (you have a page that encrypts a default password EXACTLY the same way that your normal password hashing works).|||sorry mr.douglas
i am not able to understand
can u give me more details please
Thanking u
sasidar|||I really can't, without providing all the code to do it, and I do not have time for that.
All you need to do is do the exact same one-way hashing on a default password (for instance, "password") and save that as the users new password, and in some way notify the user of the new password.
This book:
http://www.microsoft.com/mspress/books/6501.asp
has lots of information on how to do this kind of thing.