Conexão com MS-SQL e Delphi Prism

Delphi

18/05/2009

Aguem ta conseguindo conexão na unha com o Prism, estou tentando assim:

method _Default.Page_Load(sender: Object; e: EventArgs);
var
Conn : System.Data.SqlClient.SqlConnection;
Cmd : System.Data.SqlClient.SqlCommand;
DataRead: System.Data.SqlClient.SqlDataReader;

begin

Conn.ConnectionString:=ConfigurationManager.ConnectionStrings(´Conexao´).ToString;
Cmd.Connection:=Conn;
Cmd.CommandText:=´SELECT * FROM USUARIOS´;
Try
Conn.Open;
DataRead:=Cmd.ExecuteReader;
While DataRead.Read do
Begin
// use the fetched information to populate the menusystem

GridView1.DataSource := DataRead;
GridView1.DataBind;

end;

finally
Conn.Close;
End;

Esta correto essa maneira??? Se alguem puder me ajudar, eu agradeço muito.


Pauloroger

Pauloroger

Curtidas 0

Respostas

Guinther

Guinther

18/05/2009

uses
System.Data.SqlClient;

method _Default.Page_Load(sender: Object; e: EventArgs);
begin
var con := new SqlConnection(ConfigurationManager.ConnectionStrings[´Conexao´].ConnectionString);
var SQL := ´SELECT * FROM USUARIOS´;
var cmd := new SqlCommand(SQL,con);
con.Open();
try
var dr := cmd.ExecuteReader();
GridView1.DataSource := dr;
GridView1.DataBind();
finally
con.Close;
end;
end;

Guinther Pauli
MCP,MCAD,MCSD.NET,MCTS,MCPD
Delphi Certified
Arquiteto .NET


GOSTEI 0
Pauloroger

Pauloroger

18/05/2009

Valeu Pauli

Minha empresa comprou o Prism por indicação minha e ainda não tinha feito funcionar, agora rolou, obrigado.


GOSTEI 0
POSTAR