picscream Posted May 6, 2009 at 11:53 AM Report #261832 Posted May 6, 2009 at 11:53 AM SQL= "INSERT INTO Encomendas_Temp (ID, Id_CLiente,DataR, codARTIGO,qtd) values (" _ & ID & "," _ & Id_CLiente & ",'" _ & DataR & "','" _ & codArtigo & "'," _ & QTD & ")" cnCM.Execute(SQL) Dá-me erro na ultima linha de codigo, na parte do execute não consigo perceber porquê.
freaklori Posted May 6, 2009 at 03:05 PM Report #261868 Posted May 6, 2009 at 03:05 PM Dim D As SqlDataReader = New SqlCommand(Sql, A tua conexcao).ExecuteReader(); D.Read(); Para saberes se introduziu algum resultado D.RecordsAffected=1 FAÇO TUDO COM DUAS LINHAS DE CÓDIGO;
Hellblazer Posted May 9, 2009 at 04:28 PM Report #262650 Posted May 9, 2009 at 04:28 PM Boas, Um DataReader? Um Datareader deve apenas ser utilizado para ler informação da base de dados. imo... Dim connectionString as String = "connection string aqui" Dim myConnection as New SqlConnection(connectionString) Dim SQL as String = "Insert Into Clientes (Nome, Telefone) Values ('André',111111111)" Dim RowsAffected as Integer Dim myCommand as New SqlCommand(SQL, myConnection) RowsAffected = myCommand.ExecuteNonQuery() There are two ways to write error-free programs; only the third one works.
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