only first row from datareader gets affected
-
sqlstr = "select country , city FROM tbl_data WHERE RID in( " & ID & ") " dr = ''''''''''''''''''''exexuting the reader Ifdr.HasRows Then Whiledr.Read Dim datacountry =dr("country").ToString.Trim Dim datacity =dr("city").ToString.Trim MsgBox(datacountry & "===" & datacity) sqlstr = "SELECT user FROM tbl_info " _ & " WHERE country='" & drpcountry.SelectedItem.Text & "' AND city='" & drp city.SelectedItem.Text & "'" dr = ''''''''''''''''''''exexuting the reader Ifdr.HasRows Then Whiledr.Read sqlstr = "IF EXISTS (SELECT user, country, city FROM tbl_info " _ & " WHERE user='" &dr("user").ToString.Trim & "'" _ & " AND country='" & datacountry & "' AND city='" & datacity & "')" _ & " UPDATE tbl_info set user='" &dr("user").ToString.Trim & "' " _ & " WHERE user='" &dr("user").ToString.Trim & "' AND country='" & datacountry & "' AND city='" & datacity & "' " _ & " Else " _ & " INSERT INTO tbl_info(user,country, city) " _ & " VALUES ('" &dr("user").ToString.Trim & "','" & datacountry & "','" & datacity & "')" ''''''''''exexuting the query........ End While End If End While End If but in this only the first record from the country and city gets affected. all the records obtained in the reader shld get affected how do i rectify it
-
sqlstr = "select country , city FROM tbl_data WHERE RID in( " & ID & ") " dr = ''''''''''''''''''''exexuting the reader Ifdr.HasRows Then Whiledr.Read Dim datacountry =dr("country").ToString.Trim Dim datacity =dr("city").ToString.Trim MsgBox(datacountry & "===" & datacity) sqlstr = "SELECT user FROM tbl_info " _ & " WHERE country='" & drpcountry.SelectedItem.Text & "' AND city='" & drp city.SelectedItem.Text & "'" dr = ''''''''''''''''''''exexuting the reader Ifdr.HasRows Then Whiledr.Read sqlstr = "IF EXISTS (SELECT user, country, city FROM tbl_info " _ & " WHERE user='" &dr("user").ToString.Trim & "'" _ & " AND country='" & datacountry & "' AND city='" & datacity & "')" _ & " UPDATE tbl_info set user='" &dr("user").ToString.Trim & "' " _ & " WHERE user='" &dr("user").ToString.Trim & "' AND country='" & datacountry & "' AND city='" & datacity & "' " _ & " Else " _ & " INSERT INTO tbl_info(user,country, city) " _ & " VALUES ('" &dr("user").ToString.Trim & "','" & datacountry & "','" & datacity & "')" ''''''''''exexuting the query........ End While End If End While End If but in this only the first record from the country and city gets affected. all the records obtained in the reader shld get affected how do i rectify it
Have you ever used a debugger ?
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
-
sqlstr = "select country , city FROM tbl_data WHERE RID in( " & ID & ") " dr = ''''''''''''''''''''exexuting the reader Ifdr.HasRows Then Whiledr.Read Dim datacountry =dr("country").ToString.Trim Dim datacity =dr("city").ToString.Trim MsgBox(datacountry & "===" & datacity) sqlstr = "SELECT user FROM tbl_info " _ & " WHERE country='" & drpcountry.SelectedItem.Text & "' AND city='" & drp city.SelectedItem.Text & "'" dr = ''''''''''''''''''''exexuting the reader Ifdr.HasRows Then Whiledr.Read sqlstr = "IF EXISTS (SELECT user, country, city FROM tbl_info " _ & " WHERE user='" &dr("user").ToString.Trim & "'" _ & " AND country='" & datacountry & "' AND city='" & datacity & "')" _ & " UPDATE tbl_info set user='" &dr("user").ToString.Trim & "' " _ & " WHERE user='" &dr("user").ToString.Trim & "' AND country='" & datacountry & "' AND city='" & datacity & "' " _ & " Else " _ & " INSERT INTO tbl_info(user,country, city) " _ & " VALUES ('" &dr("user").ToString.Trim & "','" & datacountry & "','" & datacity & "')" ''''''''''exexuting the query........ End While End If End While End If but in this only the first record from the country and city gets affected. all the records obtained in the reader shld get affected how do i rectify it
-
From you code, it seems that the SqlDataReader variable 'dr' is re-builds again within the first while loop. Use another variable for inner data reader.
I was hoping to instead teach him how to debug his own code, one run through in the debugger should have told him what was wrong.
Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )