September 5, 2007

Execute a SQL Statement with Variable Parameters

When you need to execute the same SQL statement (in general an UPDATE) multiple times with different parameter values you can use the PrepareStatement method like this: Connection conn=null;PreparedStatement pst=null;String[] nm=new String[3];int[] nc=new int[3];…try {nm[0]=”Costescu”,nm[1]=”Alexandrescu”,nm[2]=”Popovici”;nc[0]=234423;nc[1]=123344;nc[2]=534562;pst=conn.prepareStatement(“UPDATE Table1 SET Nume=? WHERE Nr_cont=?”); for(int i=0;i&lt=2;i++) { pst.setString(1,nm[i]); pst.setInt(2,nc[i]); pst.executeUpdate(); } }catch (SQLException e){System.out.println(e.getMessage());}…

Changing Assembly Versions During Runtime Using the Web.Config File

You can change the assembly version quickly by including the bindingRedirect element in the web.config file. For example, suppose you need to redirect a particular old version dll hit to a new version. The following code shows how to redirect from version to &ltruntime&gt &ltassemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″&gt To redirect

It All Adds Up

while ago I responded to a newsgroup post in which the poster had a table of inventory changes containing start and end dates, as well as the amount that was added. The poster wanted to be able to determine the inventory in stock at any given date. I gave him