|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Read and update a tableboth read and update selected records in a table? I want to do something with each one and then update a column on that record before moving to the next record. For example: cmdSelectStaff = New OleDbCommand(strSQL, conFileData) dtrStaff = cmdSelectStaff.ExecuteReader() While dtrStaff.Read() dtrStaff("column") = "xyz" dtrStaff.Update End While I cannot find an .update method. Is there a different reader I should be using? Thanks. David With MARS you can do it pretty easily, otherwise you'd just need two
connections. Using this example, just subsititue my second Select statement with an Update statement http://msmvps.com/blogs/williamryan/archive/2004/05/13/6383.aspx Show quote "David" <dlch***@lifetimeinc.com> wrote in message news:OBGKXWu9GHA.5064@TK2MSFTNGP04.phx.gbl... > Using VS2005, ASP.Net and SQL Server. What ADO command set do I need to > both read and update selected records in a table? I want to do something > with each one and then update a column on that record before moving to the > next record. > > For example: > cmdSelectStaff = New OleDbCommand(strSQL, conFileData) > > dtrStaff = cmdSelectStaff.ExecuteReader() > > While dtrStaff.Read() > > dtrStaff("column") = "xyz" > > dtrStaff.Update > > > > End While > > I cannot find an .update method. Is there a different reader I should be > using? Thanks. > > David > > I have a few questions of my own:
1) If this is SQL Server why aren't you using the SqlClient provider? 2) If this is SQL Server why aren't you doing this UPDATE in place? Why bring the rows to the client, work some logic and send them back updated? This can all be done (in virtually all cases) on the server in a procedure or simply in an UPDATE statement. 3) What lead you believe that this would work? -- Show quote____________________________________ William (Bill) Vaughn Author, Mentor, Consultant Microsoft MVP INETA Speaker www.betav.com/blog/billva www.betav.com Please reply only to the newsgroup so that others can benefit. This posting is provided "AS IS" with no warranties, and confers no rights. __________________________________ Visit www.hitchhikerguides.net to get more information on my latest book: Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) Between now and Nov. 6th 2006 you can sign up for a substantial discount. Look for the "Early Bird" discount checkbox on the registration form... ----------------------------------------------------------------------------------------------------------------------- "W.G. Ryan [MVP]" <WilliamRyan@nospam.gmail.com> wrote in message news:usYlmlu9GHA.3620@TK2MSFTNGP04.phx.gbl... > With MARS you can do it pretty easily, otherwise you'd just need two > connections. Using this example, just subsititue my second Select > statement with an Update statement > http://msmvps.com/blogs/williamryan/archive/2004/05/13/6383.aspx > "David" <dlch***@lifetimeinc.com> wrote in message > news:OBGKXWu9GHA.5064@TK2MSFTNGP04.phx.gbl... >> Using VS2005, ASP.Net and SQL Server. What ADO command set do I need to >> both read and update selected records in a table? I want to do something >> with each one and then update a column on that record before moving to >> the next record. >> >> For example: >> cmdSelectStaff = New OleDbCommand(strSQL, conFileData) >> >> dtrStaff = cmdSelectStaff.ExecuteReader() >> >> While dtrStaff.Read() >> >> dtrStaff("column") = "xyz" >> >> dtrStaff.Update >> >> >> >> End While >> >> I cannot find an .update method. Is there a different reader I should be >> using? Thanks. >> >> David >> >> > > I am doing this in ASP.Net page on the server, not the client.
HTH David Show quote "William (Bill) Vaughn" <billvaRemoveT***@nwlink.com> wrote in message news:%239qzMsu9GHA.3760@TK2MSFTNGP02.phx.gbl... >I have a few questions of my own: > 1) If this is SQL Server why aren't you using the SqlClient provider? > 2) If this is SQL Server why aren't you doing this UPDATE in place? Why > bring the rows to the client, work some logic and send them back updated? > This can all be done (in virtually all cases) on the server in a procedure > or simply in an UPDATE statement. > 3) What lead you believe that this would work? > > -- > ____________________________________ > William (Bill) Vaughn > Author, Mentor, Consultant > Microsoft MVP > INETA Speaker > www.betav.com/blog/billva > www.betav.com > Please reply only to the newsgroup so that others can benefit. > This posting is provided "AS IS" with no warranties, and confers no > rights. > __________________________________ > Visit www.hitchhikerguides.net to get more information on my latest book: > Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) > Between now and Nov. 6th 2006 you can sign up for a substantial discount. > Look for the "Early Bird" discount checkbox on the registration form... > ----------------------------------------------------------------------------------------------------------------------- > > "W.G. Ryan [MVP]" <WilliamRyan@nospam.gmail.com> wrote in message > news:usYlmlu9GHA.3620@TK2MSFTNGP04.phx.gbl... >> With MARS you can do it pretty easily, otherwise you'd just need two >> connections. Using this example, just subsititue my second Select >> statement with an Update statement >> http://msmvps.com/blogs/williamryan/archive/2004/05/13/6383.aspx >> "David" <dlch***@lifetimeinc.com> wrote in message >> news:OBGKXWu9GHA.5064@TK2MSFTNGP04.phx.gbl... >>> Using VS2005, ASP.Net and SQL Server. What ADO command set do I need to >>> both read and update selected records in a table? I want to do >>> something with each one and then update a column on that record before >>> moving to the next record. >>> >>> For example: >>> cmdSelectStaff = New OleDbCommand(strSQL, conFileData) >>> >>> dtrStaff = cmdSelectStaff.ExecuteReader() >>> >>> While dtrStaff.Read() >>> >>> dtrStaff("column") = "xyz" >>> >>> dtrStaff.Update >>> >>> >>> >>> End While >>> >>> I cannot find an .update method. Is there a different reader I should >>> be using? Thanks. >>> >>> David >>> >>> >> >> > >
Show quote
http://msconline.maconstate.edu/tutorials/ASPNET20/ASPNET09/aspnet09-10.aspx"David" <dlch***@lifetimeinc.com> wrote in message
news:OBGKXWu9GHA.5064@TK2MSFTNGP04.phx.gbl... > Using VS2005, ASP.Net and SQL Server. What ADO command set do I need to both read and update selected records in a table? I want > to do something with each one and then update a column on that record before moving to the next record. > > For example: > cmdSelectStaff = New OleDbCommand(strSQL, conFileData) > > dtrStaff = cmdSelectStaff.ExecuteReader() > > While dtrStaff.Read() > > dtrStaff("column") = "xyz" > > dtrStaff.Update > > > > End While > > I cannot find an .update method. Is there a different reader I should be using? Thanks. > > David > > |
|||||||||||||||||||||||