gregurs Posted June 5, 2012 at 11:32 PM Report Share #460762 Posted June 5, 2012 at 11:32 PM (edited) boa noite estou com problema ao adicionar cliente, no form editarcliente tenho uma datagrid e um botão para adicionar no qual tenho este código e o problema é que é suposto ao carregar no adicioar abrir o formcliente em branco para preencher mas o que me faz é aparece o primeiro registo. con = new System.Data.SqlClient.SqlConnection(); con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"; con.Open(); SqlCommand command1 = con.CreateCommand(); command1.CommandText = "SELECT MAX(Codigo) FROM Clientes"; int num = (Int32)command1.ExecuteScalar(); num++; con.Close(); Clientes c = new Clientes(num,"Novo"); ClientesForm cf = new ClientesForm©; cf.Show(); Edited June 5, 2012 at 11:33 PM by gregurs Link to comment Share on other sites More sharing options...
Caça Posted June 6, 2012 at 12:53 PM Report Share #460853 Posted June 6, 2012 at 12:53 PM Tens algum código no load desse form? Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
gregurs Posted June 7, 2012 at 12:39 AM Author Report Share #461133 Posted June 7, 2012 at 12:39 AM tenho uma função para me mostrar na datagrid os dados que estão na base de dados Link to comment Share on other sites More sharing options...
renafi Posted June 7, 2012 at 08:23 AM Report Share #461146 Posted June 7, 2012 at 08:23 AM (edited) então o problema pode ser esse. Poe aqui o código que tens no Form_Load Ps: e estou a achar estranho criares o objecto Clientes e depois abrires a form sem enviares esse objecto. Edited June 7, 2012 at 08:24 AM by renafi Oracle Certified Professional - AdministraçãoOracle Certified Professional - Pl/sqlMCPD - Microsoft Certified Professional DeveloperMCTS - Microsoft Certified Technology Specialist Link to comment Share on other sites More sharing options...
gregurs Posted June 7, 2012 at 01:14 PM Author Report Share #461180 Posted June 7, 2012 at 01:14 PM (edited) já resolvi o problema é que não tinha tirado do formcliente o tableadapter e ele estava a carregar o tableadapter porisso e que não dava obrigado ajuda Edited June 7, 2012 at 01:15 PM by gregurs Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now