Click here to Skip to main content
15,914,446 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questioneasy XML question Pin
jcrussell20-Dec-05 16:48
jcrussell20-Dec-05 16:48 
AnswerRe: easy XML question Pin
Steve Pullan20-Dec-05 17:45
Steve Pullan20-Dec-05 17:45 
GeneralRe: easy XML question Pin
jcrussell20-Dec-05 18:04
jcrussell20-Dec-05 18:04 
GeneralRe: easy XML question Pin
Steve Pullan21-Dec-05 15:58
Steve Pullan21-Dec-05 15:58 
Question2k3 VB.net import Pin
miltond20-Dec-05 15:28
miltond20-Dec-05 15:28 
AnswerRe: 2k3 VB.net import Pin
Steve Pullan20-Dec-05 15:47
Steve Pullan20-Dec-05 15:47 
GeneralRe: 2k3 VB.net import Pin
miltond20-Dec-05 16:00
miltond20-Dec-05 16:00 
QuestionSQL Update command with VB.NET Pin
Chaos Machine20-Dec-05 12:26
Chaos Machine20-Dec-05 12:26 
Hello everybody. I have a weird error message coming up every time i try to use the Update command with a access database. The message says that there is a syntax error with the SQL command. I search the Internet and the syntax of my command seems to be right.
Here is the code:

============================================================================
Public Sub updateRecord(ByVal entryToChange As String, ByVal oldString As String, ByVal newString As String)
Dim SQLString As String
Dim strConnection As String = OleDbConnection1.ConnectionString
Dim objTransaction As OleDbTransaction
Dim connect As New OleDbConnection(strConnection)
SQLString = "UPDATE tblIns SET " & entryToChange & " = '" & newString & "' WHERE Ins = '" & oldString & "'"

Dim cmd As New OleDbCommand(SQLString, connect)
connect.Open()
Try
cmd.ExecuteNonQuery()

Catch ex As Exception
MsgBox(ex.ToString)
End Try
connect.Close()
connect.Dispose()
Me.Close()

End Sub

============================================================================

I have a value that changes (newString) and a value that i know it's the same (oldString). entryToChange is the entry that i'm trying to change (eg Date, or FirstName etc) So basicly i'm trying to change a value of a record where the oldString stays the same. But i get the error "Syntax error with UPDATE command". What is going on?

And is there a way to update a record when the entry that is changing is not the same all the time? Meaning in one record the first name may change and all other entries (eg last name, address etc) stays the same, in the other the last name may change and the rest of the entries will stay the same. In VB6 i used to use something like:

==============================================================
DatIns.Recordset.Edit
DatIns.Recordset.Fields("Date").Value = lbldate.Caption
==============================================================

but in vb.NET i can't find something like this. Thank you for your help, and Merry Christmas to all.


Still trying to find the way

-- modified at 18:27 Tuesday 20th December, 2005
QuestionRe: SQL Update command with VB.NET Pin
dptalt21-Dec-05 2:40
dptalt21-Dec-05 2:40 
AnswerRe: SQL Update command with VB.NET Pin
Chaos Machine21-Dec-05 10:58
Chaos Machine21-Dec-05 10:58 
GeneralRe: SQL Update command with VB.NET Pin
dptalt21-Dec-05 17:01
dptalt21-Dec-05 17:01 
QuestionReceive data in VB App from Shell Pin
depotdog20-Dec-05 10:37
depotdog20-Dec-05 10:37 
AnswerRe: Receive data in VB App from Shell Pin
depotdog20-Dec-05 11:10
depotdog20-Dec-05 11:10 
GeneralRe: Receive data in VB App from Shell Pin
depotdog20-Dec-05 12:01
depotdog20-Dec-05 12:01 
QuestionRetrieving email attchment from POP3 server using vb.net Pin
raviee_india20-Dec-05 10:20
raviee_india20-Dec-05 10:20 
QuestionCombobox Selected Index Pin
eatwork20-Dec-05 7:02
eatwork20-Dec-05 7:02 
AnswerRe: Combobox Selected Index Pin
albCode20-Dec-05 21:06
albCode20-Dec-05 21:06 
GeneralRe: Combobox Selected Index Pin
eatwork23-Dec-05 7:20
eatwork23-Dec-05 7:20 
AnswerRe: Combobox Selected Index Pin
Roy Heil21-Dec-05 4:01
professionalRoy Heil21-Dec-05 4:01 
GeneralRe: Combobox Selected Index Pin
eatwork23-Dec-05 7:24
eatwork23-Dec-05 7:24 
Questionadd an unmanaged dll to vb app deployment Pin
depotdog20-Dec-05 6:37
depotdog20-Dec-05 6:37 
AnswerRe: add an unmanaged dll to vb app deployment Pin
rwestgraham22-Dec-05 21:39
rwestgraham22-Dec-05 21:39 
GeneralRe: add an unmanaged dll to vb app deployment Pin
depotdog23-Dec-05 5:16
depotdog23-Dec-05 5:16 
QuestionMozilla Browser in VB Pin
Bigfatdummy20-Dec-05 6:10
Bigfatdummy20-Dec-05 6:10 
AnswerRe: Mozilla Browser in VB Pin
Dave Kreskowiak20-Dec-05 8:22
mveDave Kreskowiak20-Dec-05 8:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.