Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Posted in Uncategorized | 1 Comment

Problem of the Day (Live Spaces not updated)

            Past few days I am trying to publish blogs related to Tech Ed 2006. but with new windows spaces live I am keep on getting some JavaScript error and publish entry button remains  disabled and I am not able to update my space. See following screen where publish entry is disable and in status bar below you can see JavaScript error

 

            Any help??

 

            (P.S. – by the way I have added this blog using email service of msn spaces)

 

 

 

 
Regards,
Mayank Pujara (contactmayank83@hotmail.com)
Send Your Comments Here


Express yourself with gadgets on Windows Live Spaces Try it!
Posted in Uncategorized | 19 Comments

Tech Ed 2006 India (Mumbai)

I had privilege to attend Tech Ed this Year. I have attended following session.

˜ Extending the ASP.NET Provider model [Janakiram MSV]
˜ AJAX for ASP.NET Developers – Atlas.net[Pratibha Kumar]
˜ Using CLR inside SQL Server: Best Practices [Nauzad Kapdia]
˜ A Peep at the Future .NET Languages: LINQ [Sanjay Vyas]
˜ Microsoft Visual Studio 2005 Team System: Enterprise-Class Source Control[SS Ramakant]
˜ TECH.ED DEMO SHOOTOUT[Gaurav Khanna & Vineet Gupta]
˜ Hosting CLR 2.0 [Gaurav Khanna]
˜ Hacker Proofing Your Apps: Writing Robust Code that can Withstand Attacks by the Bad Guys[Vineet Gupta]
˜ Sharepoint 2007 for Developers [TNC Venkatarangan]
˜ Developer Productivity with VSTS: Automated Unit Testing [Ashutosh Tiwari]
˜ BizTalk 2006: Whats in for Developers [Nauzad Kapadia]

liked all of them but still AJAX and LINQ certanally stands out above all..will provide you more details on this ASAP.

Regards,
Mayank Pujara (contactmayank83@hotmail.com)
Send Your Comments Here


Check the weather nationwide with MSN Search Try it now!
Posted in Uncategorized | 2 Comments

“Underlying Connection Was Closed” Error Messages When You Call a Web Service

Following is scenario for our problem

 

1)                          We have Windows Service Application which calls Web service every specific time period. We have logic that only one web service instance will be running at a time. See the following code is from Window Service which calls web service.

 

           

/// <summary>

/// Timer Event

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

private void CIMAutoUpdateTimer_Elapsed(object sender, ElapsedEventArgs e)

 {

      try

{

  //check any webservice instance exist or not

  //isWebServiceInstaceExist = false means no webservice instance exist you can create new one

   if(isWebServiceInstaceExist ==false)

    {

   //Set WebServiceInstaceExist = true so no webservice instance will be created before response of this webservice retunrns

   isWebServiceInstaceExist =true;

   //create webservice instance

   CIMAutoUpdateInterface cimInterface = new CIMAutoUpdateInterface();

              

   //get timeout from config

cimInterface.Timeout = Convert.ToInt32(ConfigurationSettings.AppSettings["CIMAutoUpdateTimeOut"]);

//call web method

InterfaceResponse interFaceResponse =  cimInterface.ProcessRecords();

                          

//log return Response

objLogger.Info("Web Service Response :: " + interFaceResponse.Response);

 

//Set WebServiceInstaceExist = false so new webservice instance will be created

isWebServiceInstaceExist =false;

   }

 else

   {

   objLogger.Info("Web Service instace Already Exist :: ");

   }

                          

}             

catch( Exception exc)

{

   isWebServiceInstaceExist =false;

   objLogger.Info("Exception Occurred in the event." + "Exception Message::" +   exc.Message + " Stack Trace ::" + exc.StackTrace);

}             

}

 

           

2)                          now if one web service instance runs  for more than one Hours we are getting exception in window service as follows

 

2006-03-09 10:42:46,691 [2844] INFO  CIMAutoUpdateLogger [] – Exception Occurred in the event.Exception Message::The underlying connection was closed: An unexpected error occurred on a receive. Stack Trace ::   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)

   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)

   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

   at CIMAutoUpdateService.CIMAutoUpdateService.CIMAutoUpdateInterface.ProcessRecords()

   at CIMAutoUpdateService.CIMAutoUpdate_Test.CIMAutoUpdateTimer_Elapsed(Object sender, ElapsedEventArgs e)

 

 

Ø       I have searched for this error on Net and found solution that you needs to set KeepAlive = False in GetWebRequest method. I have done this as well still above error is coming on deployment server.        

 

 

Ø       Now above error comes only on deployment server only which is having Windows 2003 server as OS. But I have tested locally with window XP and window 2003 Server. With the both OS there is no error coming locally.  Even both local and deployment server is having same .Net Framework installed (1.1 SP1)

 

Ø       One more observation is that only if web service instance runs more than one hour than above exception is generated other wise application runs smoothly. But I have checked all settings in server and configuration there is no where 1 hours time out setting at all.

 

Now problem is that web service is going to update so many records at time so most of the time our web method will be running more than 1 hour

 

Well I have seen one Kb article on following link which says its .net Bug but since its working fine locally I do not think this is anything related to .net framework

 

http://72.14.203.104/search?q=cache:Qihy3DwDzVUJ:support.microsoft.com/kb/819450+underlying+connection+closed++webRequest.KeepAlive&hl=en&gl=us&ct=clnk&cd=5

           

any Comments ??

Regards,

Mayank Pujara (contactmayank83@hotmail.com)

Send Your Comments Here


Save time by starting a search from any Web page with the MSN Search Toolbar-FREE!
Posted in Uncategorized | 3 Comments

Visual Studio Express is FREE

Visual Studio "Express" Editions have been declared as available for FREE! (yipee.. yipee..yipee)

From http://blogs.msdn.com/danielfe/archive/2006/04/19/579109.aspx :

Visual Studio 2005 Express Editions including Visual Basic, Visual C#, Visual J#, Visual C++, and Visual Web Developer Express will be free permanently!

Thanks abhi for sharing this

Posted in Uncategorized | 1 Comment

Populate Dataset from CSV (When CSV Data File Contains Comma (,)

Below Mention Function Will Not Work Properly if text Value in File Contains comma(,).

 

If you are Having Comma in File while Reading Data From Text Whole DataRow is Copying to First Column.

you Can also Use stream Reader but Stream Reader is aslo Having same Problem while reading file if Data Row Contains comma you will get New Line Charater Added as First and Last Charater.

 

Follwing Code Will Work Fine.

 

 

            /// <summary>

            /// Returns Datatable From .Text/.csv File

            /// </summary>

            /// <param name="tempFileName">File Name To Which Query Should Run</param>

            /// <param name="tempFilePath">Directory Name Where File Reside</param>

            /// <returns></returns>

            /// <remarks>Above Function Read File and Based on Schema Defination File will be converted in To DataTable

            /// For This you Require Schema.ini File

            /// </remarks>

            private DataTable GetDataTableFromFileNew(string tempFileName,string tempFilePath)

            {

                  StreamReader sr = new StreamReader(tempFileName);

                 

                  String line = String.Empty; 

                  String firstLine = String.Empty;

                  int intLineIdentifier = 0;

                  DataTable dtCIMExtract= null;

                  int intStartIndex = 1;

                  int intLastDeductIndex = 2;

                  int intStringlength;

                                   

                  // Read and display lines from the file until the end of

                  // the file is reached.

                  while ((line = sr.ReadLine()) != null)

                  {

                        if(intLineIdentifier == 0)

                        {

                              firstLine = line;

                              dtCIMExtract= GenerateColumnForDataTable(firstLine);

                              intLineIdentifier = intLineIdentifier + 1;

                        }

                        else

                        {

                              if(line.IndexOf(",") > 0)

                              {

                                    intStringlength = line.Length – intLastDeductIndex;

                                    line = line.Substring(intStartIndex,intStringlength );

                              }

                              DataRow drRow = dtCIMExtract.NewRow(); 

                              string[] strColumndata = line.Split(seprator); 

                              for(int colno= 0;colno < strColumndata.Length;colno++)

                              {

                                    drRow[colno] = strColumndata[colno].ToString();        

                              }

                              dtCIMExtract.Rows.Add(drRow);  

                        }

                  }

                 

 

                  //Return DataTable     

 

                  return dtCIMExtract;

           

            }

            private DataTable GenerateColumnForDataTable(string strColumns)

            {

                 

                  DataTable dtCodeDesc =new DataTable();

 

                  string[] strColumnArray = strColumns.Split(seprator); 

                  //Create

                 

                  foreach(string strcol in strColumnArray)

                  {

                        //Create columns

                        dtCodeDesc.Columns.Add(new DataColumn(strcol ,typeof(string)));

                  }

                 

                  return dtCodeDesc;

            }

 

 

Happy Coding!!!!!!

Posted in Uncategorized | 10 Comments

Populate Dataset from CSV

Populate Dataset from CSV

 

Following Function Will Return DataTable from .Text/.CSV File

 

 

/// <summary>

/// Returns Datatable From .Text/.csv File

/// </summary>

/// <param name="tempFileName">File Name to Which Query Should Run</param>

/// <param name="tempFilePath">Directory Name Where File Reside</param>

/// <returns>DataTable</returns>

/// <remarks>Above Function Read File and Based on Schema Defination File will be converted in To DataTable

/// For This you Require Schema.ini File

/// </remarks>

private DataTable GetDataTableFromFile(string tempFileName,string tempFilePath)

            {

                  //Create a ODBC connection and open the same

                  string connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ="+tempFilePath;

                  OdbcConnection odbcConnection = new OdbcConnection(connectionString);

                  odbcConnection.Open(); 

 

                  //Load data using sql  

                  string sql;

                  //sql = "Update " + tempFileName + " set Name=’1′ where dunsNumber=’797370970′"  ;

                  sql = "Select * From " + tempFileName;

                  OdbcDataAdapter da = new OdbcDataAdapter(sql, odbcConnection); 

 

                  //Creating DataSet and Filling Data into Dataset DS

                  DataTable dtCIMExtract= new DataTable();

                 

                  da.Fill(dtCIMExtract);

                 

                  // Close the connection

                  odbcConnection.Close();

 

                  return dtCIMExtract;

           

            }

 

 

 

///Example of Schema.ini File  

 

[TempFile.csv]

ColNameHeader=True

Format=Delimited(|)

MaxScanRows=250

CharacterSet=ANSI

Col1=Col1Name Char Width 255

Col2= Col2Name Char Width 255

 

           

 

            See Schema.ini Requires File name to Which Query should Fired. So better you copy your data to any Temp file and then use this File. Schema.ini also contains definition of delimiter and finally contains Column Details.

 

           

Happy Coding!!!!!!

 

 

 

 

 

 

Posted in Uncategorized | 3 Comments