Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. unicode

unicode

Scheduled Pinned Locked Moved C#
help
9 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    ybasha
    wrote on last edited by
    #1

    Hi there, i try this in my code but some problem in the updated stmt can u help me shoot wht the problem is the compiler thro me error: The name Var1 does not exist in the class or namespace of the project.... here is the codesnippet: string strsql; DataTable dt; SqlDataAdapter da; SqlConnection objConn = new SqlConnection("data source=yusuff;user id=sa;password=sa;initial catalog=Heritage"); dt = new DataTable(); strsql = "select * from Articles_production"; da = new SqlDataAdapter(strsql,objConn); da.Fill(dt); if(dt.Rows.Count > 0) { //foreach (DataRow dr in dt.Rows) //ervy loop for (int i=0;i

    K C R A G 6 Replies Last reply
    0
    • Y ybasha

      Hi there, i try this in my code but some problem in the updated stmt can u help me shoot wht the problem is the compiler thro me error: The name Var1 does not exist in the class or namespace of the project.... here is the codesnippet: string strsql; DataTable dt; SqlDataAdapter da; SqlConnection objConn = new SqlConnection("data source=yusuff;user id=sa;password=sa;initial catalog=Heritage"); dt = new DataTable(); strsql = "select * from Articles_production"; da = new SqlDataAdapter(strsql,objConn); da.Fill(dt); if(dt.Rows.Count > 0) { //foreach (DataRow dr in dt.Rows) //ervy loop for (int i=0;i

      K Offline
      K Offline
      KaptinKrunch
      wrote on last edited by
      #2

      If your code looks the way that it is posted. the for loop is incomplete.

      Y 2 Replies Last reply
      0
      • K KaptinKrunch

        If your code looks the way that it is posted. the for loop is incomplete.

        Y Offline
        Y Offline
        ybasha
        wrote on last edited by
        #3

        no i posted my codesnippet as For (int i=0;i

        1 Reply Last reply
        0
        • K KaptinKrunch

          If your code looks the way that it is posted. the for loop is incomplete.

          Y Offline
          Y Offline
          ybasha
          wrote on last edited by
          #4

          ur text box is truncate the code...pls check the code project page regards ybasha

          1 Reply Last reply
          0
          • Y ybasha

            Hi there, i try this in my code but some problem in the updated stmt can u help me shoot wht the problem is the compiler thro me error: The name Var1 does not exist in the class or namespace of the project.... here is the codesnippet: string strsql; DataTable dt; SqlDataAdapter da; SqlConnection objConn = new SqlConnection("data source=yusuff;user id=sa;password=sa;initial catalog=Heritage"); dt = new DataTable(); strsql = "select * from Articles_production"; da = new SqlDataAdapter(strsql,objConn); da.Fill(dt); if(dt.Rows.Count > 0) { //foreach (DataRow dr in dt.Rows) //ervy loop for (int i=0;i

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            ybasha wrote:

            'where identifier='" + Id +"'";

            Unless your unique ID is a string, you need to remove the quotes. Christian Graus - Microsoft MVP - C++

            1 Reply Last reply
            0
            • Y ybasha

              Hi there, i try this in my code but some problem in the updated stmt can u help me shoot wht the problem is the compiler thro me error: The name Var1 does not exist in the class or namespace of the project.... here is the codesnippet: string strsql; DataTable dt; SqlDataAdapter da; SqlConnection objConn = new SqlConnection("data source=yusuff;user id=sa;password=sa;initial catalog=Heritage"); dt = new DataTable(); strsql = "select * from Articles_production"; da = new SqlDataAdapter(strsql,objConn); da.Fill(dt); if(dt.Rows.Count > 0) { //foreach (DataRow dr in dt.Rows) //ervy loop for (int i=0;i

              R Offline
              R Offline
              Rob Graham
              wrote on last edited by
              #6

              Since you didn't cut an paste the real code (as evidinced by the incomplete for statement) it is possible that the error message is correct: Var1 doesn't exist in the posted code. its var1... C# is after all case sensitive... This would be better done as a parameterized query anyway. Parameters have fewer issues with text characters (don't mind unescaped single quotes for instance) and so are less likely to give strange errors than dynamically built SQL. I notice that two or more of your replacements are replaceing unicode characters with double quotes, which likely totally corrupt the concatenated query sting (causing it to appear to terminate early). Using parameters would avoid that issue as well. Christian's observation is also likely a problem, and is another that would be avoided by using parameters. Building up SQL statements by concatenating stuff like this is bad practice for a number of reasons (increased garbage generation from all the string reallocations, vulnerability to SQL injection attack, etc). [edit] On top of all that, all the string variables (var1, var2, etc) are declared inside the scope of the for loop, and so do not exist outside of it (where your sql sting is declared and concatenated)...move the declarations to before the for loop, and this might have a chance [edit] Absolute faith corrupts as absolutely as absolute power Eric Hoffer All that is necessary for the triumph of evil is that good men do nothing. Edmund Burke -- modified at 0:00 Wednesday 26th October, 2005

              1 Reply Last reply
              0
              • Y ybasha

                Hi there, i try this in my code but some problem in the updated stmt can u help me shoot wht the problem is the compiler thro me error: The name Var1 does not exist in the class or namespace of the project.... here is the codesnippet: string strsql; DataTable dt; SqlDataAdapter da; SqlConnection objConn = new SqlConnection("data source=yusuff;user id=sa;password=sa;initial catalog=Heritage"); dt = new DataTable(); strsql = "select * from Articles_production"; da = new SqlDataAdapter(strsql,objConn); da.Fill(dt); if(dt.Rows.Count > 0) { //foreach (DataRow dr in dt.Rows) //ervy loop for (int i=0;i

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                It looks like Var1 is outside the scope of the loop.

                1 Reply Last reply
                0
                • Y ybasha

                  Hi there, i try this in my code but some problem in the updated stmt can u help me shoot wht the problem is the compiler thro me error: The name Var1 does not exist in the class or namespace of the project.... here is the codesnippet: string strsql; DataTable dt; SqlDataAdapter da; SqlConnection objConn = new SqlConnection("data source=yusuff;user id=sa;password=sa;initial catalog=Heritage"); dt = new DataTable(); strsql = "select * from Articles_production"; da = new SqlDataAdapter(strsql,objConn); da.Fill(dt); if(dt.Rows.Count > 0) { //foreach (DataRow dr in dt.Rows) //ervy loop for (int i=0;i

                  G Offline
                  G Offline
                  Gulfraz Khan
                  wrote on last edited by
                  #8

                  did you spell the variables correctly (i.e Var1 != var1)?

                  1 Reply Last reply
                  0
                  • Y ybasha

                    Hi there, i try this in my code but some problem in the updated stmt can u help me shoot wht the problem is the compiler thro me error: The name Var1 does not exist in the class or namespace of the project.... here is the codesnippet: string strsql; DataTable dt; SqlDataAdapter da; SqlConnection objConn = new SqlConnection("data source=yusuff;user id=sa;password=sa;initial catalog=Heritage"); dt = new DataTable(); strsql = "select * from Articles_production"; da = new SqlDataAdapter(strsql,objConn); da.Fill(dt); if(dt.Rows.Count > 0) { //foreach (DataRow dr in dt.Rows) //ervy loop for (int i=0;i

                    L Offline
                    L Offline
                    lmoelleb
                    wrote on last edited by
                    #9

                    Not really related to your question, but I hope you are aware that you can convert between code pages/encodings in a few lines (this looks like UTF-8 read as for example cp1252). If it is indeed the case do something like this: byte[] bytes = System.Text.Encoding.GetEncoding(1252).GetBytes(sourceString); string result = System.Text.Encoding.UTF8.GetString(bytes);

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups