View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
javydreamercsw[_3_] javydreamercsw[_3_] is offline
external usenet poster
 
Posts: 1
Default SQL Queries in VBA

Since no answered yet my earlier post, I've been working with sq
queries trying to fix that. Dunno if someone knows about queries in VB
but here we go...

sql = "SELECT * FROM Sección WHERE courseno = '"
Range("Información!B4").Value & "'"
Set rs = cn.Execute(sql)
If Not rs.EOF Then 'No existe
sql = "UPDATE Sección SET section = '"
Range("Información!B3").Value & "' WHERE courseno = '"
Range("Información!B4").Value & "'"
MsgBox sql
Set rs = cn.Execute(sql)

The first query (select) works fine but when trying to do the Updat
query it always give me a syntax error. It seems like a right write
query to me. Same happens with this query:

sql = "INSERT INTO Sección (courseno,section) VALUES('"
Range("Información!B4").Value & "','" & Range("Información!B3").Value
"'"
Set rs = cn.Execute(sql)

Any Idea

--
Message posted from http://www.ExcelForum.com