exception has been thrown by the target of an invocation
15/07/2008
0
Alguém poderia dar uma luz???
SEGUE ABAIXO A CLASSE:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace DAL
{
public class Gerenciador
{
private string ConStr = @´Data Source=Fernanda_TI\SQLEXPRESS;Initial Catalog=Gerenciador;Integrated Security=True´;
public DataSet Select()
{
SqlConnection con = new SqlConnection(ConStr);
string SQL = ´select * from Modulo´;
SqlCommand cmd = new SqlCommand(SQL, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
public void Update(int ID_Modulo, string Nome_Modulo)
{
SqlConnection con = new SqlConnection(ConStr);
string SQL = ´update Modulo set Nome_Modulo=@Nome_Modulo where ID_Modulo=@ID_Modulo´;
SqlCommand cmd = new SqlCommand(SQL,con);
cmd.Parameters.AddWithValue(´@Nome_Modulo´, Nome_Modulo);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
Dotnet
Posts
16/07/2008
Ricardo Silva
tenta abrir a conexão antes referenciala ao SqlCommand
public DataSet Select(){ SqlConnection con = new SqlConnection(ConStr); string SQL = "select * from Modulo"; con.Open(); SqlCommand cmd = new SqlCommand(SQL, con); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); con.Close(); return ds; } public void Update(int ID_Modulo, string Nome_Modulo){ SqlConnection con = new SqlConnection(ConStr); string SQL = "update Modulo set Nome_Modulo=@Nome_Modulo where ID_Modulo=@ID_Modulo"; con.Open(); SqlCommand cmd = new SqlCommand(SQL,con); cmd.Parameters.AddWithValue("@Nome_Modulo", Nome_Modulo); cmd.ExecuteNonQuery(); con.Close(); }
ve se da certo...
na duvida soh posta
16/07/2008
Ricardo Silva
ficou faltando adicionar mais um parametro no upDate
cmd.Parameters.AddWithValue("@ID_Modulo", Nome_Modulo)
na duvida soh posta
17/07/2008
Ricardo Silva
eai.. ja resolveu seu problema???
com o select e UpDate
Clique aqui para fazer login e interagir na Comunidade :)