problema al insertar en seql server 2005
Publicado por cristina (2 intervenciones) el 12/06/2011 12:51:24
Hola.
Tengo un problema cuando quiero insertar datos en una bse de datos sql server 2005, no tengo ningun fallo en el codigo pero no me lo inserta, aqui dejo el codigo a ver si me podeis ayudar, gracias.
final Button bMenu2=(Button) findViewById(R.id.menu2);
bMenu2.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
Statement stmt=null;
int numarticulo=0;String sql=null;
try {stmt=
miconexion.createStatement();
res=stmt.executeQuery("Select isnull(nNumArticulos,0) from ComandaArticulos where nNumComanda="+n+" and cIdArticulo='002'");sql=
"Select isnull(nNumArticulos,0) from ComandaArticulos where nNumComanda="+n+" and cIdArticulo='002'";
res.next();numarticulo=
res.getInt("nNu mArticulos");} catch (SQLException e) {
numarticulo=0;
}
try{
if (numarticulo == 0) {sql=
"INSERT INTO ComandaArticulos (nNumComanda, cIdArticulo, nNumArticulos) VALUES("+n+",'00
Tengo un problema cuando quiero insertar datos en una bse de datos sql server 2005, no tengo ningun fallo en el codigo pero no me lo inserta, aqui dejo el codigo a ver si me podeis ayudar, gracias.
final Button bMenu2=(Button) findViewById(R.id.menu2);
bMenu2.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
Statement stmt=null;
int numarticulo=0;String sql=null;
try {stmt=
miconexion.createStatement();
res=stmt.executeQuery("Select isnull(nNumArticulos,0) from ComandaArticulos where nNumComanda="+n+" and cIdArticulo='002'");sql=
"Select isnull(nNumArticulos,0) from ComandaArticulos where nNumComanda="+n+" and cIdArticulo='002'";
res.next();numarticulo=
res.getInt("nNu mArticulos");} catch (SQLException e) {
numarticulo=0;
}
try{
if (numarticulo == 0) {sql=
"INSERT INTO ComandaArticulos (nNumComanda, cIdArticulo, nNumArticulos) VALUES("+n+",'00
Valora esta pregunta


0