Jump to content

Recommended Posts

Posted
 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ê.

Posted

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;

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.