Thursday, July 17, 2008

Drinking Coffee A Pattern....

Jai Gurudev
Now days we have started AHTAVAKRA GITA.
We start our day with Group Sadhan and after that we listen to the GITA, now on the 2nd day of the Ashtavakra Gita (15th July 08),



I woke up early at 4:30 am and had my bath after that i reached to center for Group sadhna but do i really missing something........!? i asked to my self and LOL, i found the answer that i didnt drink my tea...;) i immediately realized my problem and directly head towards a Shop for early morning TEA.



When i reached to shop, ordered a tea...........whille drinking my tea. i came to know Ahhhh......I just LOST my vollate Now I immediatly went to the road and went to the center the same way i had gone to the Tea Shop.......and after reaching to the center i realized that i didn’t brought my vollate, i just worrying for nothing. I was happy at that time,after i went and paid to the Shopekeeper and come back to the Center and done my Kria.

After Kriya we started the knowledge session, and 1st thing speak is about Patterns,Habits and he gives the examples of Coffee only.
He said that we have our own pattern i.e Drinking Coffee and several other examples.
Which is really cause of misery and it really pinches in my heart, after that i make a point to drink tea atleast not in the early morning and strictly not when some knowledge session is going on.........Guru is great

Hope in the upcoming days of Ashtavakra Gita, nothing that sort of thing will happen
Jai gurdev

Monday, July 7, 2008

How I learnt the RudraBhishek.......

Actually I was waiting for the inner call to write something about rudrabhishek, I guess today is the day.



It all started during Feb-04 when we heard that guruji is coming to ahmedabad for shivratri before that we had done some seva to gather people and also sold some kria passes as always and the day had come when 50+ people went to ahmedabad early morning 5 o’clock for Long kria which was taken by guruji himself and afterwards seva and then rudrapuja started in the evening.

We were bit of thrilled as explained by Guruji, then he took the meditation and it was amazing as always afterwards, truly speaking not much interested in rudrabhishek when it started but as soon as PANCHA GAVYA SNANAM STARTED i was literally amazed by seeing that imagine 1 egg shaped transparent object fully covered by the yellowish brown white kind of something (which is Milk, curd, ghee, honey and sugar), looks so nice.

Then started Namakam- chamankam as per Guruji namakam means salt which is present every where like wise seeing Shiv Tatva in everything for example it says I am seeing Shiv in Fisherman and I am bowing to that shiv in that person etc, like wise it consists plenty of other things, then started Chamakam which is asking everything to Lord shiv saying I need good sleep, iron, gold, food almost everything which is available in this universe.



Afterwards when puja was over Gurji dance, I am in AOL since 1999 I have never ever seen guruji dancing like that before. And that was the time where almost everybody started crying and that was the turning point I decided to learn Rudrabhishek.

My father is very much co-operative to me, and then Grace part starts when I started learning naturally my father arranged teacher me who comes on every sat-sun to our place and teaches me Rudrabhishek in Gujarat it is consists of 10 adhyay .8 of Rudrabhieshek + 2 shanti adhyay and it is of 70 pages long but see the grace I had learnt it within 3 months time which is continuous 24 Days only, my teacher was so impressed with me that he said he had taught plenty of students but I was student who learnt it very quickly and what we chant here in ashram is even more simple as it consist of only 2 Adhyay (NaMaKaM-ChMaKam).

Till today I am performing rudrabhishek everyday and those 2 hours of my day is always amazing no matter how I feel that time during the puja is simply amazing.

Thanks to Guruji by whose grace I learnt it..!

Here the best part is everything arranged for me automatically and the learning period was so reduced that till today I am amazed that how did I learnt it…!? It was so without any effort

And during my learning period of it I encounter plenty of concepts attached to rudrabhishek which we will take in some other posts.
Jai Gurudev
Parth

Batch Insert from GridView



Some time back i have done simple timesheet with no extra thing doing just insert my data from Gridview which will come as forms to user and User will Fill the form and and click on the BUTTON and his data for that day will get Saved for that Day.



Here in above image where button event is there so that using this we can insert the data into the database.

Here, Logic is very simple we are looping through the Grid and inserting the data by finding control within the Asp:TemplateField and we are done doing it.

Thanks
Hope this will be helpful to someone.

Parth

Friday, July 4, 2008

Row to Column Conversion with help of ReportViewer


some time back i was in need for converting row of my data to column as my rows were of Project names of an Organization and Columns where of TaskNames...so being a Database person i tried doing it using SQL but after that thought it may increase my server's CPU cycle, so better to handle this scenario with report viewer..... and some how i was able to d it successfully.....


1. Add .rdlc file in your project solution


2. Add .xsd in your App_code folders







3. Drag and drop Matrix report then put your required field into the Matrix Report's column and part and datapart







4. then bind your reportviewer into code behind, this is the tricky part as this will help you having total control of report ...if in future you want to add Dropdown and On DropDown selection you want to show Report, it is easily possible.


Tell me if any clarification is req. cause here you can do many things like, chnage the back color of cell of your report by just providing VB code (of course conditionally and dynamic.......) you can also change Textsize,Italic,Underline etc..conditionaly.... All of the above is possible in the design view of.rdlc file.

Thanks & Regards


Parth

Heirarchical Grid or Parent childgridView using javascript







A very simple thing which is most often required by the developers is creating the Hierarchical grid view or in other words Parent-Child Grid....

Some of the Organizations where they maintain Parent-Child relationships in their process required such kind of data representation....

Scenario:
In a certain organization you need to have a Project Under particular project you must have tasks,this will create your Hierarchical Grid

1.We have to create 1 grid and then add TemplateField Column,after put 2nd Grid inside the TemplateField Column put DataKeyName of Key Column which common in both Grid'd data like ProejctGroup then bind the Grid

2.Put + sign in First Column and put that inside Div tab in your grid view column














3.then Bind the 2nd grid on rowdataboundevent








4.put the javascript code as shown below

























Now simple you parent grid will bind your child grid and it will go on and on doind Hierarchi of data and you are done doing it...!
cheers
Hope this will be helpful to some one.
Thanks
Parth

Present moment

Some time back when i was in Ashram, we were with the course participants......and satsang was just about to begin at that time we told course participants ( of Part-I) and we were just talking to eachother experience at that time one of us just spoke that rain usualy never comes at the time of satsang and now we just dont even bother about it also as it is tasken for granted...;) &....



suddenly rain started and we all have to rush to the VM andVM was jam packed....after some time guruji came and we were just alone with him .....me and vinod has wave hand to them he done the same with us......after 1 second or so , he turned around and looked at me and ask me to be careful as i was about to touch a live wire...and i was certainly not aware of it.....;)
It shows guruji remains in present moment always as he takes care for every one like child to him

Now, the day come, it was 29th June
again we went for satsang on Sunday...again the same situation it was about to rain and it rained also but at this time satsang was going on....

Guruji came at the place of satsang usually in some car but now he came in small car .just running to the amphitheater and it was raining ...even though it was raining when guruji comes everybody forgets everything and keep indulge them selves in satsang ....after some moments guruji looks up at the sky where he just glance for moment or 2, rain stops like some one had switched off the TAP,

It was amazing scene....!

I have always seen that Rain Never Comes at the time of satsang, but i have seen first time that even if rain comes, if guruji wants it to stop.Rain doesn't have anyother option but to STOP.

Jai Gurdev

Parth

Thursday, July 3, 2008

Textbox's Value to Gridview's Textbox without PostBack

Have you thought of having such a Textbox which will insert values into Gridview's Textbox without performing Postback...it may seems childish , but thought some might need it.





Now,Lets Hit it



1. Here you have to register an array of Tetxbox from which you want to take the value as well Textbox in grid where you want to put value.



put this code in Page_Load Event or rowdatabound event.....

after adding above code now turn for javascript:
2. Now comes the design part where you have to just assign a Tetxboxes from above code one must easily understand that which textbox is which ( ok ok dont confuse yourself...........)
this values of the texboxes for example. in javascript code txtnotes is from Gridview (which is shown into VB code) and as txtboxIds shown in javascript code is the textbox which is going to populate in the Modalpopup from AjaxcontrolToolkit.

And above modalpopup is into the gridview's column (templete column)so for each row 1 modalpopup will generate and you are just assigning the value of 1 textbox to other......

hope this helps some one.

Thanks
Patrh

Note: Becareful with the code,cause as it is generating the modalpopup for each row in my case i have data also in my modalpopup, so i am forced to do like that ,
sometime it happens that you will find some error from browser that Stop running the script? , cause your browser will not able to load whole javascript,for that there is work around like one can simply do the paging for this kind of scenario so browser doesn't have to load fully.

Automatic Scheduled database Backup

Necessicity is the mother of invention.......thought i am not inventor,
some time back i was requested to give some utility to the clients that they will schedule the backup database and in certains Drive i.e in C:\Dump folder all of my backup should go....

It is done by creating simple procedure which is shown below:
But before doing so, one must register their devices , by just executing following command
1. EXEC sp_addumpdevice 'disk','mydiskdump','C:\Dump'
after doing this, one will run the procedure and put it in scheduler, your dump will go to C:\drive
USE [master]
GO
/****** Object: StoredProcedure [dbo].[custom_proc_backupdatabase] Script Date: 07/04/2008 10:04:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[custom_proc_backupdatabase] as
-- THIS PROCEDURE IS FOR MAINTANANCE PURPOSE FOR DATABASE
--CREATED BY PARTH ON 5TH MAY 2008
declare
@db varchar(300),
@dbname varchar(300),
@sql nvarchar(1000),
@backupdate varchar(50)
declare c1 cursor for
select name from master..sysdatabases where name not in ('master','tempdb','model','msdb','SharePoint_AdminContent_2edfaf57-7f7a-43d9-9171-e63b1d726f91')
order by name
select @backupdate={fn curdate()}
--Before running this procedure please register your type of backup here e.g DISK,TAPE,NETWORKDISK
-- for that you just have to run following command here :
-- USE master
-- EXEC sp_addumpdevice 'disk','mydiskdump','C:\Dump'
begin
open c1
fetch c1 into @db
while (@@fetch_status=0)
begin
-- FOLLOWING IS THE USE OF DYNAMIC SQL WHERE WE ARE GETTING DATABASE_NAME AND LOGFILE NAME
set @sql='select @dbname=name from '+@db+'.dbo.sysfiles where fileid=1'
execute sp_executesql @sql,N'@dbname varchar(300) OUT,@db varchar(300)',@dbname OUT,@db
select * from master.dbo.sysfiles
--######################################################################################################
--NOW BY FOLLOWING CODE WE ARE EXECUTING DATABASE COMMAND DYNAMICALLY
-- BY JUST PROVIDING DB NAME
-- Following command will truncate the Log file as well
set @sql='USE '+@db+';'
set @sql=@sql+'BACKUP DATABASE '+@db+''
set @sql=@sql+' TO DISK=''C:\DUMP\'+@db+'_'+@backupdate+''' WITH FORMAT ;'
PRINT @sql
--######################################################################################################
execute sp_executesql @sql,N'@dbname varchar(300)',@dbname
fetch c1 into @db
end
end
close c1
deallocate c1

now.................lol
you are done doing............Cheers

Parth

PS: I am new to SQL, please send me your feedback for better of improvement of this procedures

Truncating logfile Dynamically using SP

Hi,
some days back, it happens to 1 of my clients datacenter that suddenly they were unable to insert the data in the database, we tried so many thing like checking for database connectivity, or any other process is going on....etc etc...

suddenly we found out that there is tremendous amout of data is there in LOG file so, for temporary purpose we have take a back ( of course we first stop the process and instances.....as it is recommended) then we create a new Log file for that database

Now the problem was the data flow was so much that we have to do something that will automatically delete the log file so we try building a procedure which will run as per the schedule and deletes the log file and getting back to it's normal size.......

Below is the code for that:

USE [master]
GO
/****** Object: StoredProcedure [dbo].[proc_trunclogfiles] Script Date: 03/09/2008 13:55:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[proc_trunclogfiles] as
-- THIS PROCEDURE IS FOR MAINTANANCE PURPOSE FOR TRUNCATIONG LOG FILES
--CREATED BY PARTH ON 3RD MARCH 2008
declare
@db varchar(300),
@logname varchar(300),
@sql nvarchar(1000)
declare c1 cursor for
select name from master..sysdatabases where name not in ('master','tempdb','model','msdb')
order by name
begin
open c1
fetch c1 into @db
while (@@fetch_status=0)
begin
-- FOLLOWING IS THE USE OF DYNAMIC SQL WHERE WE ARE GETTING DATABASE_NAME AND LOGFILE NAME
set @sql='select @logname=name from '+@db+'.dbo.sysfiles where fileid=2'
execute sp_executesql @sql,N'@logname varchar(300) OUT,@db varchar(300)',@logname OUT,@db
--######################################################################################################
--NOW BY FOLLOWING CODE WE ARE EXECUTING THE TRUNCATE LOG COMMAND DYNAMICALLY
-- BY JUST PROVIDING DB NAME AND LOGNAME
-- Following command will truncate the Log file as well
--set @sql='USE '+@db+';'
--set @sql=@sql+'BACKUP LOG '+@db+' with truncate_only ;'
--set @sql=@sql+' DBCC SHRINKFILE('+@logname+');'
--######################################################################################################
-- FOLLOWING IS THE ANOTHER METHOD TO DO IT...!
set @sql='USE '+@db+';'
set @sql=@sql+' DUMP TRANSACTION '+@db+' WITH NO_LOG;'

execute sp_executesql @sql,N'@logname varchar(300)',@logname
fetch c1 into @db
end
end
close c1
deallocate c1

Hope this will help some one.

Thanks
Parth
PS: as i am new to SQL, please let me know if there is any problem with code or i have done something wrong

Function for calculating Working hours

Hi,
If you want to calculate simple working hours, i think this might help some,
Below function will return the working hour for the days between

CREATE FUNCTION [dbo].[WorkHours] ( @str_start DATETIME, @str_end DATETIME) RETURNS INT
AS
BEGIN
RETURN
(SELECT ((total_days / 7) * 5 + total_days % 7 -
CASE WHEN 6 BETWEEN start_weekday AND end_weekday
THEN 1 ELSE 0 END -
CASE WHEN 7 BETWEEN start_weekday AND end_weekday
THEN 1 ELSE 0 END) * 8 FROM (SELECT total_days, start_weekday,
start_weekday + total_days % 7 - 1
FROM (SELECT DATEDIFF(day, @start_date, @str_end) + 1,
DATEPART(WEEKDAY, @str_start + @@DATEFIRST - 1) ) AS T
(total_days, start_weekday) ) AS D
(total_days, start_weekday, end_weekday) );
END

Thought this might help someone who is struggling with the calculating the working hours, yes this may not serve the best result in customized situation given by clients but it happens some time that you just need to calculate something very straight.

Thanks
Parth

DB Mails to Lotus Notes




some days back 1 of our client requested us to setup a functionality where in their organization when ever person will assigned to task, he /she will get the task here the twist was they need the functionality in Lotus notes and they need it in simple table where each and every details should appear like what is his/her task name ,start date,end date ,% complete etc....

so we decided to use database for this assignment, as our task is to sent it to lotus notes first we found out that lotus Note is accepting the HTML or not and we found out that it is taking HTML format and hence we were able to do it....that way..............
otherwise we can also use XML and transform it using XSLT but here it is of no need....

Hope this will help to someone
Thanks
Parth
PS: I am new to SQL, please let me know if i have done any mistake in it.

Parent grid Details into child on mouse hover



Hi,
some days back i was wondering that how gmail has created detail of the sender where i am able to see his/her Pics and details with other options like sending mails ...etc

Thanks to AjaxToolkit, i was able to achive the same and code snippet is as follows:




and then simple "OnRowdatabound" event will do the whole trick for us......

If e.Row.RowType = DataControlRowType.DataRow Then
Dim gv As GridView = e.Row.FindControl("GridView2")
Dim dbSrc As New SqlDataSource
dbSrc.ConnectionString = ConfigurationManager.ConnectionStrings("ProjectServer_ReportingConnectionString3").ConnectionString
dbSrc.SelectCommand = "SELECT * FROM projectserver_reporting.dbo.customdetailsuserview WHERE projectname= '" & _
e.Row.DataItem("projectname").ToString & "'"
gv.DataSource = dbSrc
gv.DataBind()
End If

so using above simple method i have achive the effect like gmail............

Thanks

Parth