<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'DataAccessObject..' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'DataAccessObject..' posted on the 'C#' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Wed, 23 May 2012 13:28:50 -0700</pubDate>
    <lastBuildDate>Wed, 23 May 2012 13:28:50 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>DataAccessObject..</title>
      <link>http://www.programmersheaven.com/mb/csharp/389854/389854/dataaccessobject/</link>
      <description>Hello people.. I'm new to this forums.. Plus, its my first day on a job (Just finished college) And my first assignment is.. Converting a VB6 code to a C# code.. I'm stuck at understanding the programmers code plus the comments on the program is not really helpfull..&lt;br /&gt;
&lt;br /&gt;
Here is a sample that I tried using the VB to C# converter..&lt;br /&gt;
&lt;br /&gt;
------Initialized variables------------------------------&lt;br /&gt;
//ado connection&lt;br /&gt;
    private ADODB.Connection conData = new ADODB.Connection();&lt;br /&gt;
    private ADODB.Recordset recData = new ADODB.Recordset();&lt;br /&gt;
    private ADODB.Recordset recRNum = new ADODB.Recordset();&lt;br /&gt;
    //dao connections&lt;br /&gt;
    DAO.Database daodb;&lt;br /&gt;
    //UPGRADE_WARNING: Arrays in structure daors may need to be initialized before they can be used. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?
keyword="814DF224-76BD-4BB4-BFFB-EA359CB9FC48"'&lt;br /&gt;
    DAO.Recordset daors;&lt;br /&gt;
    //validation&lt;br /&gt;
    string strSql;&lt;br /&gt;
    string strCode;&lt;br /&gt;
    string msgAmtErr;&lt;br /&gt;
    string msgRecNoErr;&lt;br /&gt;
    string strRecNo;&lt;br /&gt;
    string tmpErr;&lt;br /&gt;
    bool flgCode;&lt;br /&gt;
    bool flgDte;&lt;br /&gt;
    bool flgForm;&lt;br /&gt;
    bool flgAmt;&lt;br /&gt;
    bool flgrecNo;&lt;br /&gt;
    bool flgExists;&lt;br /&gt;
    string mainAmtErr;&lt;br /&gt;
    //getting bank code&lt;br /&gt;
    string xBnkInd;&lt;br /&gt;
    string Sqlbank;&lt;br /&gt;
    string subBnkInd;&lt;br /&gt;
    //passed parameters&lt;br /&gt;
    string xBank;&lt;br /&gt;
    string xFilePath;&lt;br /&gt;
    string xTrdate;&lt;br /&gt;
    //sys object&lt;br /&gt;
    Scripting.FileSystemObject fsys = new Scripting.FileSystemObject();&lt;br /&gt;
    string sFile;&lt;br /&gt;
    string CDRCFile;&lt;br /&gt;
    Scripting.TextStream txtErr;&lt;br /&gt;
    //balancing figures&lt;br /&gt;
    decimal cmpFri;&lt;br /&gt;
    decimal cmpSat;&lt;br /&gt;
    decimal cmpSun;&lt;br /&gt;
    decimal cmpMon;&lt;br /&gt;
    decimal cmpTue;&lt;br /&gt;
    decimal cmpWed;&lt;br /&gt;
    decimal cmpThur;&lt;br /&gt;
    decimal amtFri;&lt;br /&gt;
    decimal amtSat;&lt;br /&gt;
    decimal amtSun;&lt;br /&gt;
    decimal amtMon;&lt;br /&gt;
    decimal amtTue;&lt;br /&gt;
    decimal amtWed;&lt;br /&gt;
    decimal amtThur;&lt;br /&gt;
    decimal schedAmt;&lt;br /&gt;
    decimal schedCmp;&lt;br /&gt;
   &lt;br /&gt;
    short EODval;&lt;br /&gt;
    string SchedDay;&lt;br /&gt;
    bool flgAmtValid;&lt;br /&gt;
    bool flgBalStat;&lt;br /&gt;
    string msgBalErr;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
------One of the function that failed to update to C#-------&lt;br /&gt;
 //Get compared amount for RB&lt;br /&gt;
    private void SetCmpAmountRB()&lt;br /&gt;
    {&lt;br /&gt;
         // ERROR: Not supported in C#: OnErrorStatement&lt;br /&gt;
&lt;br /&gt;
        {&lt;br /&gt;
            if (!string.IsNullOrEmpty(daors.Fields("amt1").Value)
) cmpFri = (decimal)daors.Fields("amt1").Value;&lt;br /&gt;
            if (!string.IsNullOrEmpty(daors.Fields("AMT2").Value)
) cmpSat = (decimal)daors.Fields("AMT2").Value;&lt;br /&gt;
            if (!string.IsNullOrEmpty(daors.Fields("AMT3").Value)
) cmpSun = (decimal)daors.Fields("AMT3").Value;&lt;br /&gt;
            if (!string.IsNullOrEmpty(daors.Fields("AMT4").Value)
) cmpMon = (decimal)daors.Fields("AMT4").Value;&lt;br /&gt;
            if (!string.IsNullOrEmpty(daors.Fields("AMT5").Value)
) cmpTue = (decimal)daors.Fields("AMT5").Value;&lt;br /&gt;
            if (!string.IsNullOrEmpty(daors.Fields("AMT6").Value)
) cmpWed = (decimal)daors.Fields("AMT6").Value;&lt;br /&gt;
            if (!string.IsNullOrEmpty(daors.Fields("AMT7").Value)
) cmpThur = (decimal)daors.Fields("AMT7").Value;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
I can't understand what those "if" statements mean (I mean, if not string is null or empty????) , plus the (!string.isNullorEmpty) return value is. &lt;br /&gt;
&lt;br /&gt;
I also did a little research about dao, and on one web site, it states that DAO is pretty much useless now.. and I can't get the commands right for C# to extract data from the data base (using a MSExcel database)&lt;br /&gt;
&lt;br /&gt;
I hope you people can help me.. I've been trying to figure this thing out for 5 days, and still no luck.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/csharp/389854/389854/dataaccessobject/</guid>
      <pubDate>Sun, 26 Apr 2009 05:17:50 -0700</pubDate>
      <category>C#</category>
    </item>
    <item>
      <title>Re: DataAccessObject..</title>
      <link>http://www.programmersheaven.com/mb/csharp/389854/389868/re-dataaccessobject/#389868</link>
      <description>Jeeze - so I'm not saying this out of any kind of disrespect, but one of your biggest issues right now is that you are working for a company that has a VB6 code foundation. However, they are taking a good step in moving to dotnet (assuming you are building business applications and it looks like you are)&lt;br /&gt;
&lt;br /&gt;
So I'm not sure how much of this code you are recognizing or not but they are simply opening a database connection and grabbing some data from a database here - hopefully all of the missing query and connection code was just simply omitted by you. You can actually replace this with any one of a multitude of connectors available in the dotnet libraries depending on your database type.&lt;br /&gt;
&lt;br /&gt;
the conversion error you are seeing is from the error handling system that VB6 had. In dotnet you will need to replace this with a try/catch statement.&lt;br /&gt;
&lt;br /&gt;
Somewhere in the vb6 code you will find "On Error GoTo something" or "On Error DoNext" or whatever&lt;br /&gt;
&lt;br /&gt;
What this simply means is that in the current code scope, from the on error statement onward, if an error occurs do the specified action.&lt;br /&gt;
&lt;br /&gt;
In dotnet you need to wrap the code you want to handle errors on inside of a try block, and then use catch blocks to handle the various different types of errors you want to handle.&lt;br /&gt;
&lt;br /&gt;
so...&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
try
{
    //Some code that might fail for whatever reason
}
catch (ExceptionType e)
{
    // If an exception occurs matching the specified exception type
    // then this code will execute and load the exception data into e
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
It also looks like the code right below the conversion error is probably giving you some problems as well.&lt;br /&gt;
&lt;br /&gt;
the string class in .Net has a static method on it that will check if a string is either null or empty (IsNullOrEmpty) which accepts a string value and returns a boolean result. So that is fine if the "Value" property on the field objects you are checking is in fact a string.&lt;br /&gt;
&lt;br /&gt;
Buuut - if they are a string then the very next statement is a conversion statement that is attempting to convert a string into a decimal - and this will fail.&lt;br /&gt;
&lt;br /&gt;
However, if the Value property is an object that is holding a decimal, then in the null or empty check you should call the ".ToString()" method on the .Value parameter in order to convert it to a string so the ".IsNullOrEmpty" method is happy.&lt;br /&gt;
&lt;br /&gt;
Otherwise if the .Value parameter is in fact a string and you want to convert it into a decimal - then the "decimal" class has a method on it called ".Parse(string)" or ".TryParse(string, out decimal)" that will get you the decimal value you need to work with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
but to be completely honest - if this was originally written in VB6, I would be wary of the programmer that wrote it because the chances are he wasn't following very good practices as the VB6 language was never a strong promoter of good OOP design or practices. On top of the fact that you are converting from unmanaged to managed code - I would say get a spec sheet and a team together and design + write the new and improved version natively in a dotnet language.&lt;br /&gt;
&lt;br /&gt;
sorry for sounding so oppinionated, just from my personal experience trying to auto-convert from vb6 to .net is like moving from one maintenance nightmare to a worse one.&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;lt;/\/~Psightoplasm`~</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/csharp/389854/389868/re-dataaccessobject/#389868</guid>
      <pubDate>Sun, 26 Apr 2009 11:16:42 -0700</pubDate>
      <category>C#</category>
    </item>
    <item>
      <title>Re: DataAccessObject..</title>
      <link>http://www.programmersheaven.com/mb/csharp/389854/389869/re-dataaccessobject/#389869</link>
      <description>Sorry - I originally missed that you are connecting to excel data instead of an actual DB. For this you just use the standard odbc connector. &lt;br /&gt;
&lt;br /&gt;
It looks like there are some examples here - including connection strings &lt;br /&gt;
&lt;a href="http://www.codeproject.com/KB/grid/Excel_in_CS.aspx"&gt;http://www.codeproject.com/KB/grid/Excel_in_CS.aspx&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;lt;/\/~Psightoplasm`~</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/csharp/389854/389869/re-dataaccessobject/#389869</guid>
      <pubDate>Sun, 26 Apr 2009 11:28:01 -0700</pubDate>
      <category>C#</category>
    </item>
    <item>
      <title>Re: DataAccessObject..</title>
      <link>http://www.programmersheaven.com/mb/csharp/389854/389891/re-dataaccessobject/#389891</link>
      <description>I know I know.. Its just that, that VB6 program was written by a team of students doing their On-the-Job-Training, so as my first assignment to my company.. I was given that to convert it to C# (which is their forte and mail PL..)&lt;br /&gt;
&lt;br /&gt;
I'll read more and on the site you gave me. Expect to be hearing from me soon..&lt;br /&gt;
&lt;br /&gt;
(Yeah I'm **cked up on my first week on the job *sob*)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/csharp/389854/389891/re-dataaccessobject/#389891</guid>
      <pubDate>Sun, 26 Apr 2009 21:13:10 -0700</pubDate>
      <category>C#</category>
    </item>
  </channel>
</rss>
