Click here to Skip to main content
15,911,306 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello

Am here doing VB to C# conversion of some code but face some error listed below
Below is my VB Code


VB
If IsDBNull(rs.Item("raw")) Then
           new_scale = True
           sb.Append("<input type=""hidden"" name=""new_scale"" value=""1"">"

           For x = 0 To 2 ' raw = 0 To 2
               sb.Append("<tr id=""row_" & x & """>")
                   sb.Append("<td id=""row_" & x & "_col_0"">")




and it is my C# code after conversion

XML
if (Information.IsDBNull(rs.Item("raw")))
        {
            new_scale = true;
            sb.Append("<input type=\"hidden\" name=\"new_scale\" value=\"1\">");

            for (x = 0; x <= 2; x++)
            {
                sb.Append("<tr id=\"row_" + x + "\">");
                sb.Append("<td id=\"row_" + x + "_col_0\">");

            }
}





After coversion the above VB code to C# using online conversion tool following error occur:
if (Information.IsDBNull(rs.Item("raw"))):

The name 'Information' does not exists in current context.
Anyone please help me to fix it
Posted
Updated 25-May-15 20:42pm
v2

You can always translate code (not "convert"!) automatically. Please see my past answer:
Code Interpretation, C# to VB.NET[^].

Most reliable and quality method is using open-source ILSpy.

You got a very good advice by Maciej Los in his comment to your previous question: stop doing it! Do follow this advice.
Also, stop re-posting the same question; this is considered as abuse.

—SA
 
Share this answer
 
Comments
Maciej Los 26-May-15 2:58am    
+5!
Sergey Alexandrovich Kryukov 26-May-15 2:58am    
Thank you, Maciej.
—SA
C#
// Try using if (Convert.IsDBNull(fieldValues[fieldCounter]))
// Get data, replace missing values with "NA" and display it.
  while (dr.Read())
  {
     dr.GetValues(fieldValues);

     for (int fieldCounter = 0; fieldCounter &lt; fieldCount; fieldCounter++)
     {
        if (Convert.IsDBNull(fieldValues[fieldCounter]))
           fieldValues[fieldCounter] = &quot;NA&quot;;
     }
     grid.Rows.Add(fieldValues);
  }
  dr.Close();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900