473,788 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Continuation of issue from 4/16/05

Cor,

I made the changes you suggested by I get an error message saying "Incorrect
syntax near the keyword 'trigger'.

What is wrong?

------------------------------ Last message from
4/17/05 -----------------------

Gary,

There are at least two things what makes that your update does not work.
You are have no commands in your dataadapter.
You use the acceptchanges wrong.

I have made some corrections typed (so watch typos) inline in this message
so look below to them.

You better create and dispose better as well the connection in those
procedures because now you don't free the connectionpool.
----------------------------------------------------------------------------
Private Sub Form2_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

Dim strSQL As String = "Select * from Contact where sysid = '" &
g_sysID & "'"
DB = New SqlClient.SqlDa taAdapter(strSQ L, CN)
dim cb as new sqlclient.sqlco mmandbuilder(db )

ES.Clear()
DB.Fill(ES, "Contact")

If ES.Tables("Cont act").Rows.Coun t > 0 Then
txtAddress.Text =
ES.Tables("Cont act").Rows(0).I tem("con1_02_03 ")
txtFirst_Name.T ext =
ES.Tables("Cont act").Rows(0).I tem("First_Name ")
txtLast_Name.Te xt =
ES.Tables("Cont act").Rows(0).I tem("Last_Name" )
End If

End Sub
--------------------------------------------------------------------------
Here is the code to update the table
--------------------------------------------------------------------------
Private Sub btnUpdate_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnUpdate.Click

Try
es.Tables(0).Ro ws(0).Item("Fir st_Name") = txtFirst_Name.T ext
es.Tables(0).Ro ws(0).Item("Las t_Name") = txtLast_Name.Te xt
es.Tables(0).Ro ws(0).Item("con 1_02_03") = txtAddress.Text ES.AcceptChange s()
delete the row above, this means that all rowstates which are set to a
changed state will be set to unchanged and the changes are accepted, so the
dataadapter has nothing to change. It is implicitly done by the dataadapter
when a change is done.
DB.Update(ES, "Contact")

Catch ex As Exception

MessageBox.Show (ex.Message)

End Try

End Sub


I hope this helps,

Cor

Nov 21 '05 #1
6 1051
Gary,

I don't see it, can you show the corrected code again? It will not be the
first time that there are misunderstandin gs.

Cor
Nov 21 '05 #2
Cor,

The code you asked me to put in was (In the Load routine)

dim cb as new sqlclient.sqlco mmandbuilder(db )

and in the (update routine), remove the following

ES.AcceptChange s()
One question though, when I create the sqlcommandbuild er, doesn't it have to
be global? Since I have the two routines, they both need to be aware of it?

Thanks,

Gary


i
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Gary,

I don't see it, can you show the corrected code again? It will not be the
first time that there are misunderstandin gs.

Cor

Nov 21 '05 #3
Gary,

You don't use the commandbuilder anymore when it has created the commands in
the dataadapter.

However,

I looked what furter in your code.
I don't see a connection.open
I don't see how you fill the g_sysID

Therefore at what moment does that error come.

cor
Nov 21 '05 #4
Cor,

Are you saying that I don't need the line with the commandbuilder? You
suggested that I put it in. g_sysID is global and gets filled when I click
on the datagrid to isolate the record I want to update. When the Load
routine executes the three text fields are populated correctly. When I do
the update, that is when I get the error message regarding the trigger.

Gary

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Oh******** ******@TK2MSFTN GP14.phx.gbl...
Gary,

You don't use the commandbuilder anymore when it has created the commands
in the dataadapter.

However,

I looked what furter in your code.
I don't see a connection.open
I don't see how you fill the g_sysID

Therefore at what moment does that error come.

cor

Nov 21 '05 #5
Gary,

I tested completly your code, however with northwind employee database.
It did completly as it should go.

\\\
Dim db As New SqlDataAdapter
Dim g_sysID As String = "1"
Dim ES As New DataSet
Dim CN As New SqlConnection _
("Server=MyServ er; DataBase=Northw ind; Integrated Security=SSPI")

Private Sub Form2_Load(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim strSQL As String = _
"Select * from Employees where Employeeid = '" & g_sysID & "'"
db = New SqlClient.SqlDa taAdapter(strSQ L, CN)
db.Fill(ES, "Employees" )
Dim cb As New SqlCommandBuild er(db)
If ES.Tables("Empl oyees").Rows.Co unt > 0 Then
txtFirst_Name.T ext = _
ES.Tables("Empl oyees").Rows(0) .Item("FirstNam e").ToString
txtLast_Name.Te xt = _
ES.Tables("Empl oyees").Rows(0) .Item("LastName ").ToString
End If
End Sub

Private Sub btnUpdate_Click (ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnUpdate.Click
ES.Tables(0).Ro ws(0).Item("Fir stName") = txtFirst_Name.T ext
ES.Tables(0).Ro ws(0).Item("Las tName") = txtLast_Name.Te xt
Try
db.Update(ES, "Employees" )
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub
///

I hope this helps,

Cor
Nov 21 '05 #6
Cor,

I created a new project, did a "cut-and-paste" of this code and it worked on
my machine. Dunno what happened with my other project but I'll check it
out. Thanks for giving me a working codeset.

Gary

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:us******** ******@TK2MSFTN GP09.phx.gbl...
Gary,

I tested completly your code, however with northwind employee database.
It did completly as it should go.

\\\
Dim db As New SqlDataAdapter
Dim g_sysID As String = "1"
Dim ES As New DataSet
Dim CN As New SqlConnection _
("Server=MyServ er; DataBase=Northw ind; Integrated Security=SSPI")

Private Sub Form2_Load(ByVa l sender As System.Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim strSQL As String = _
"Select * from Employees where Employeeid = '" & g_sysID & "'"
db = New SqlClient.SqlDa taAdapter(strSQ L, CN)
db.Fill(ES, "Employees" )
Dim cb As New SqlCommandBuild er(db)
If ES.Tables("Empl oyees").Rows.Co unt > 0 Then
txtFirst_Name.T ext = _
ES.Tables("Empl oyees").Rows(0) .Item("FirstNam e").ToString
txtLast_Name.Te xt = _
ES.Tables("Empl oyees").Rows(0) .Item("LastName ").ToString
End If
End Sub

Private Sub btnUpdate_Click (ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles btnUpdate.Click
ES.Tables(0).Ro ws(0).Item("Fir stName") = txtFirst_Name.T ext
ES.Tables(0).Ro ws(0).Item("Las tName") = txtLast_Name.Te xt
Try
db.Update(ES, "Employees" )
Catch ex As Exception
MessageBox.Show (ex.Message)
End Try
End Sub
///

I hope this helps,

Cor

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2060
by: TheDustbustr | last post by:
I just downloaded the uthread module for stackless python. Whenever I import it it says it can't find the continuation module. Anyone know where I can get it? Thanks, Dustin
0
1095
by: bgoli | last post by:
Hi Are there any existing parameter continuation routines either coded in Python or with a Python interface? TIA
2
2192
by: Jasper Recto | last post by:
I have a statement that I can't seem to use Line Continuations on it: Progress = "V:\PROGRESS\bin\prowin32.exe V:\VANTAGE\db\vantage.db_ -ininame V:\VANTAGE\vantage.ini -pf V:\VANTAGE\db\Vantage.pf -N TCP -H loc-vntg -S epic52 -ld vantage -p v:\" & ReportPath & ReportName & " -rand 2 -q -basekey ini" This is all one line and when I try to use line continuation ( _ ) I keep getting errors.
5
1571
by: Sandra-24 | last post by:
I'm not sure how complex this is, I've been brainstorming a little, and I've come up with: If the previous line ended with a comma or a \ (before an optional comment) That's easy to cover with a regex But that doesn't cover everything, because this is legal:
13
14675
by: Don | last post by:
Hi, I have an SQL string that I'm trying to code into VBA and it's giving me trouble. I tried to use line continuation and concatenation as best I can to make it work. However, I'm stuck. I know that there are limitations to the length of the string but I can't break it up properly. I'm also thinking that I need to use multiples occurrences of strsql to do so but I'm not sure how. Can someone please tell me how to break this string up?
6
2408
by: Haakon Riiser | last post by:
After a long debugging session while scripting my webmail, I believe I have traced the problem to the way httplib sends POST requests. I have compared tcpdump listings from Python 2.4.3 and 2.5.0's httplib (via urllib/urllib2), Perl's LWP::UserAgent 2.033 and Firefox 2.0. Only Python sends the request in such a way that the mailserver closes the connection before I get any data from the POST request (immediate FIN packet after the POST...
3
3433
by: psbasha | last post by:
Hi , I am following backslash ('\') as continuation of line as per the coding guidelines.Is there any other character to be used as continuation of line? Thanks in advance PSB
0
1272
by: mduff | last post by:
This is actually a great script that will help authenticate your username and password within your domain. One thing I would correct is directly above the line that indicates: Set oADsObject = oADsNamespace.OpenDSObject(strADsPath, strUserName, strPassword, 0) place an on error resume next
6
1981
by: Russ P. | last post by:
I've always appreciated Python's lack of requirement for a semi-colon at the end of each line. I also appreciate its rules for automatic line continuation. If a statement ends with a "+", for example, Python recognizes that the statement obviously must continue. I've noticed, however, that the same rule does not apply when a line ends with "and," "or," or "not." Yes, it's a minor point, but shouldn't the same rule apply? Seems like it...
3
4446
by: MLH | last post by:
I don't understand why (a) works and compiles but (b) does not... (a) Set qdfTemp = .CreateQueryDef("", _ "SELECT * FROM Employees") (b) Set qdfTemp = .CreateQueryDef("", _ "SELECT DISTINCTROW tblPmtsRcd.PmtID, tblPmtsRcd.InvoiceNumber, tblPmtsRcd.VehicleJobID,
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10118
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.