Asp.net & Sql server fundas with Rajat Jaiswal

April 22, 2013

“The app you are using not responding” Facebook payment API problem

Filed under: Asp.net,Facebook API — indiandotnet @ 3:29 am
Tags: ,

Dear All,

I think sometimes you are trying hard to resolve issue and at the end you found oops this was the problem. It happened again with me Smile.

Everything working fine and suddenly oops “Facebook payment API not working” .

Your_App_Not_responding

I checked my code somehow trapped the error code.Google it and found that the callback page not working properly.

so I tried to call it explicitly as I do and found it was working spent few hours wrote whole new code to make sure everything should work as is but not got any success.

Then by god grace  an idea came to my mind to check actual call back page define Facebook app setting.

Dam, this was the reason actually in payment callback  URL by mistake it was https while there was no certificate installed on site Sad smile.

I just turned it to http and you know what miracle again. Now Facebook payment API working.

This is surely a learning lesson for me to check the basic first Smile and if someone struggling same problem I urge you to check the callback URL first.

I puzzled lot but ultimately going for sleep with happy ending.

Enjoy learning.

Your friend

Rajat Jaiswal

April 18, 2013

SQL SERVER Database mail Problem “Microsoft.SqlServer.Management.SqlIMail.Server.Objects.Account GetAccount(Int32)” How to resolve ?

Dear All,

Sometimes it happened when this kind of issue came you did everything according to basic rules for database mail setting in SQL Server and when you try to send the mail through SQL server you got error

"Exception Type: System.NullReferenceException

Message: Object reference not set to an instance of an object.

Data: System.Collections.ListDictionaryInternal

TargetSite: Microsoft.SqlServer.Management.SqlIMail.Server.Objects.Account GetAccount(Int32)”

When you tried to resolve it you search a lot of google you did not get a proper result.

I faced this problem with SQL Server 2005 edition with SQL Server Service Pack1.

Here I am sharing how simple to resolve this.  Simplest step is to Update SQL server service Pack 2 &  SQL server service pack 3.

You can download  SQL server service pack 2 with link http://www.microsoft.com/en-us/download/details.aspx?id=9969

and SQL server Service pack 3 with link http://www.microsoft.com/en-us/download/details.aspx?id=14752

Once you install it and after restart your SQL server mail function started Isn’t it simple.

I hope this resolve the problem of my friends who searched a lot on Google but could not get a proper solution.

Enjoy.

Thanks & Best Regards,

Rajat Jaiswal

March 20, 2013

LINQ with CheckBox List–LINQ Tips

Filed under: Uncategorized — indiandotnet @ 8:16 pm

Dear All,

There are many situation where you need to comma separated values of all the checked items of a checkbox list for this situation you generally write following  code

string allowedProductfamilies = string.Empty;
foreach (ListItem lItem in chkFamily.Items)
                {
                    if (lItem.Selected)
                    {
                        allowedProductfamilies += lItem.Value + ",";
                    }
                }

Now the above code is fine but can be improve more with following lines of code you can directly replace above lines with following lines of the code

string allowedProductfamilies = string.Empty;

allowedProductfamilies = chkFamily.Items.Cast<ListItem>().Where(lItem => lItem.Selected).Aggregate(allowedProductfamilies, (current, lItem) => current + (lItem.Value + ","));

 

I am sure you like the code.

Enjoy .Net , Enjoy LINQ .

Your Friend,

Rajat Jaiswal

February 23, 2013

LINQ tip to use proper for loop

Filed under: Asp.net,LINQ,Utility — indiandotnet @ 6:39 pm
Tags: ,

Dear Friends,

As a programmer I would like to share some of the best tips which I found so far and this is one of the tip which I am going to share right away

suppose you have following  piece of code

string[] Names= namecollection.Split(GetDelimeter());

           List<string> NameList = new List<string>();
     

foreach (string name in Names)
          {
              if (!string.IsNullOrEmpty(name ))
              {
                  sb.Append(name .Trim() + ",");
                  NameList .Add(name .Trim());
              }
          }

Now you can write above  for each code  & if condition in following way

foreach (string Nam in Names.Where(Nam=> !string.IsNullOrEmpty(Nam)))
           {
               sb.Append(Nam .Trim() + ",");
             NameList .Add(Nam.Trim());
           }

It is much faster then a earlier code which shown

Hope you like this. Enjoy  Reading

Regards,

Rajat Jaiswal

February 3, 2013

String Vs StringBuilder know it – in more Detail(curious)

Filed under: Asp.net — indiandotnet @ 7:36 am
Tags: ,

Dear All,

We all know the difference between String  and StringBuilder. Like Once the String Object is define its length and content can not be modified. When we do concatenate the string a new object is created always.

While in StringBuilder  length and content can be modified even after object is created.It is faster than string etc.

So lets understand it what exactly happened inside this story.

for this I have created a windows application with 2 button and text box. The first button will handle String operation, second button handle String Builder operation and we show result in textbox. just simple one.

On string button I wrote following code.

private void btnString_Click(object sender, EventArgs e)
      {
          string strResult = string.Empty;
          for (int intI = 0; intI < 4000; intI++)
          {
              strResult = strResult + intI.ToString();
              strResult  = strResult + ",";
          }
          this.txtResult.Text = strResult;
      }

On string builder button  I wrote follow code.

private void btnStringBuilder_Click(object sender, EventArgs e)
{
StringBuilder strTest = new StringBuilder();
for (int intI = 0; intI < 4000; intI++)
{
strTest.Append(intI.ToString());
strTest.Append(";");

}

this.txtResult.Text = strTest.ToString();
}

 

Simple enough to understand nothing new . So now what lets start a CLR Profiler application

If you don’t have CLR Profiler application then you can download it from here.

Now start CLR Profiler Application by double click the exe

You will get following screen

CLR_EXE_STARTED

Now as we have created the windows application so we hit  “Start Application” button

As you click the Start Application button it will prompt for EXE file so  I provided the  exe of above project. as I  provided the path it started the exe of my project. So Now I clicked the string button as shown in below fig.

String_Run

As you see the output is printed  in textbox after the print I closed the “Form1”  windows as I closed it.

Wow  I got following screen

Memory_Allocation_After_String_Run

Which basically  showing the memory allocation of string type  operation.

same above step  I have repeated for String Builder  button. I open the String Operation EXE again then hit String Builder Button and then closed the “Form1” window and as I closed the window I got following screen which is memory allocation of String Builder

String_Builer_Result

Now just compare above result 

Comparision_String_VS_String_Builder

 

If you see above screen the memory allocation of string object is more than 250 times of StringBuilder object.  and there are more object to finalize in string operation but not in String builder. there is 91 Items in Generation 0 and 1 item in Generation 1 of String object while there is no item in String builder.

So from above comparison we can say that yes string object take more memory it makes GC busy a lot so possibility is higher that you may get “Out Of Memory exception” , your application is slow . So its better to use StringBuilder is such cases where you need to concatenate strings dynamically.

I hope you enjoyed the difference in detail . Will take care such situation and use proper string  or stringBuilder.

So enjoy the Weekend.

Thanks & Best Regards,

Rajat Jaiswal

Learn, Share, Grow knowledge

January 20, 2013

Superb option run sam single query on multiple SQL Server instances

Filed under: Sql server,Utility — indiandotnet @ 4:56 pm
Tags: , ,

Dear Friends,
Sometimes you stuck in situation where you need to run same set of queries on different servers.
Sometimes it is a real pan when you need to fetch records from all the server then basic approach you follow run query on different instance once by one.

I would like to share here one important facility provided in SQL Server management studio which is

“Register Servers”

With the help of Register Servers option you can run same query for the entire servers which you have registered.
You can access the “Register Servers” option from View ==> Register servers OR by pressing “CTRL + ALT + G” keys.

As shown below fig

Register Servers

Once you press the menu or follow above keys then you will get Register Servers option screen as shown in below fig.

Regiser server screen

You can right click on Local Server Groups and can create your own group also

Create group

Once the group is created you can move your Registered servers on which you want to run query in that group with right click move option on Group Folder

As you did this job your database server will come in the particular group folder as shown in below fig

MylocalGroupRegisterServers

Now right click on your group folder and go for option New Query
As you go for option new query a new query window will be open there
Now write proper query which you want to run on same database at different servers and execute it with F5 option
You will find when you will execute the result will show in query result window which is just below the query with starting column server name.

SinglQueryMultipleResult

Now you have option whether you want merge result or Individual result.
To check that option you need to go Tool –> Option then Query Result option as shown below fig

MergeREsultOption

This trick will help you in many ways to get the results from different server as well as to find results from different servers.

Thanks & Regards,
Rajat Jaiswal
Keep Learning, Keep Sharing

January 18, 2013

Great option “SQLCMD” run DOS command in SQL Server Managment Studio

Filed under: Sql server,Utility — indiandotnet @ 6:14 pm
Tags: , ,

Dear All,
Today I am going to share one of the interesting options of SQL Server Management studio which may be unknown to most of us.
Now you are thinking what it is? So the cool feature is you can

run DOS command in your SQL Server Management studio

.
I know your next question is how?
My answer is just follow below step
Go To Tool –> Option
After option window open you need to select Query Execution tree and Select checkbox for

SQLCMD_Option

By default, Open new queries in SQLCMD Mode

Now open new Query window and write following command
!! Dir C:\
And hit F5
You will find below in the query result you have directory & files of your current C drive.
Just check below fig to understand.

SQLCMD_Result

In this way you can run various DOS commands.
!! SSMS
!! Dir C:\New Folder

Isn’t it cool feature.

I hope you enjoyed it.

SQLCMD Option

Rocks
Keep Learning, Keep Sharing
Your friend,
Rajat Jaiswal

How to open Profiler with command prompt , Various options?

Filed under: Sql server — indiandotnet @ 2:16 am
Tags: , ,

Dear Friends,

In the last topic we got awareness like

How to open SQL server using command prompt.
In similar way we can

open profiler with command prompt

also.

So Let us start write following command on command prompt

1.  C:\>Profiler

The above command will open the profiler.

2. C:\>Profiler –E

When you write above command and press enter you will find profiler is open also a default trace started as shown in below fig

Profiler-With-Default-Trace

3. C:\> Profiler/?

When you hit enter after writing the above command you will find a popup windows which shows various option available with profiler command so just enjoy.

profiler-With-command-Various-options

Thanks & Best Regards

Rajat Jaiswal

How to open SQL Server with command prompt with various option?

Filed under: Sql server,Utility — indiandotnet @ 2:07 am
Tags: , ,

Dear All,

Today I am going to share some small dos which will helpful to open SQL Server Management Studio.

I am sure you are curious about

how to open SQL Server Management studio with command prompt.

So Let us start Currently when you go through SQL Server Management studio you have to process 2 step means first click the SQL server Management studio by clicking icon then login to the server.

Now check this out write following command in dos command prompt and press enter

C:\> ssms –E

You will find your SQL Server Management studio open without any prompt of Login authentication because here E stands for windows Authentication mode.
Now go deeper write following command

C:\>ssms –E –NOSPLASH

Now you found that the splash screen also not coming ,So similarly you can find various options to open SQL SERVER Management Studio using command prompt.

SSMS-E-NOSPLASH
To know various options let us write following command

C:\ssms/?

You will get following screen and you can any option from below screen to proceed further.

ssms

I hope you enjoyed the trick.

Thanks & Bes Regards, Rajat Jaiswal

January 12, 2013

Facebook Graph API- Is it Simple to Fetch Facebook users information with simple URL (Y/N)?

Filed under: Facebook API,Utility — indiandotnet @ 11:28 am
Tags: , ,

Dear Friends,
Today I am going to share some small tips to

access Facebook account related detail using Graph API.

Facebook Graph API is one of the easy tools to access Facebook Information and incorporate in your application.

Suppose you know the Facebook name of the person and if you want to know First name, last name, Facebook Id and Facebook page of the person then you just need to write following URL in your browser.

http://graph.facebook.com/Facebookusername

(You just need to Replace Facebook Username by Facebook actual username Or Facebook ID)

Let us try with my Facebook username when I write below URL in browser and hit enter

https://graph.facebook.com/rajat.jaiswal.902

I get following screen

Facebook ID by Facebook Usename

Similarly if I know the ID then I can also get above screen. Now write following URL in browser you will get exact same screen

https://graph.facebook.com/771700761

Going further I know curiosity increased now you want see Facebook Picture also of the person then no issue we are going to show the image also with same Facebook Graph API

For this you just need to write following URL in your browser

 

https://graph.facebook.com/FacebookId/picture (You just need to replace Facebook ID)

For example let us run it with my Facebook ID

 

https://graph.facebook.com/771700761/picture

I hope you enjoyed this information.

Thanks & Regards,
Rajat Jaiswal
Keep Learning, Keep Sharing

Next Page »

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 52 other followers