vasco16 Posted March 8, 2009 at 11:40 AM Report Share #249080 Posted March 8, 2009 at 11:40 AM boas pessoal, estou a fazer uma aplicação em vb.net e estou com um problema, queé o seguinte: Como faço para adicionar um novo registo á minha base de dados em access em interface vb.. já fiz um botao já actualiza os dados na BD só que ás vezes dá erro porque a minha BD está feita para nao deixar criar valores duplicados num certo campo e ao actualizar como vai criar um valor duplicado o programa dá erro. Outra das minhas duvidas é como é que faço aparecer automaticamente a numero automática no VB ?:S Link to comment Share on other sites More sharing options...
esquima Posted March 8, 2009 at 01:31 PM Report Share #249106 Posted March 8, 2009 at 01:31 PM http://www.portugal-a-programar.pt/index.php?showtopic=25358 ja te disse aqui como deverias fazer...tens de validar se ja existe uma linha com esse id.. Link to comment Share on other sites More sharing options...
vasco16 Posted March 8, 2009 at 01:42 PM Author Report Share #249111 Posted March 8, 2009 at 01:42 PM Dim strQuery As String = "if not exists (select * from compras where matricula= @matricula)"_ & "BEGIN INSERT INTO compras (matricula, marca, modelo) VALUES (@matricula,@marca,@modelo)END" da erro no begin :s Link to comment Share on other sites More sharing options...
esquima Posted March 8, 2009 at 02:02 PM Report Share #249121 Posted March 8, 2009 at 02:02 PM tenta assim... e k nao estou mto por dentro do acess INSERT INTO compras (matricula, marca, modelo) VALUES (@matricula,@marca,@modelo)WHERE not exists (select * from compras where matricula= @matricula) 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