473,500 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update Problem

lotus18
866 Contributor
Hello World!

I am trying to convert my project in vb6.0 to vb.net '05 ^ ^. I can add and delete records but I have a problem in updating records.

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
  2.         If AddCourse = True Then
  3.             SQLString = "Insert Into Courses ([CourseID],[Title],[Description]) Values ('" & _
  4.             txtCourseID.Text & "','" & txtTitle.Text & "','" & txtDescription.Text & "')"
  5.             Call DoTransactions(SQLString)
  6.             MessageBox.Show("New course has been sucessfully added.", _
  7.             "Course Added", MessageBoxButtons.OK, MessageBoxIcon.Information)
  8.         Else
  9.             SQLString = "Update Courses Set Title='" & txtTitle.Text & "', Description='" & _
  10.             txtDescription.Text & "' Where CourseID='" & txtCourseID.Text & "'"
  11.             Call DoTransactions(SQLString)
  12.             MessageBox.Show("New course has been sucessfully added.", _
  13.             "Course Updated", MessageBoxButtons.OK, MessageBoxIcon.Information)
  14.         End If
  15.     End Sub
  16.  
  17. Private Sub DoTransactions(ByVal StringCommand As String)
  18.         'Set Database Connection
  19.         Call SetConnection()
  20.         cmdCourses = New OleDbCommand(StringCommand, dbConnection)
  21.         cmdCourses.CommandType = CommandType.Text
  22.         rsCourses = cmdCourses.ExecuteReader
  23.         'Close Connection
  24.         rsCourses.Close()
  25.         Call CloseConnection()
  26.         'Refresh List
  27.         Call frmCourses.LoadCourses()
  28.         Me.Close()
  29. End Sub
Rey Sean
Apr 2 '08 #1
0 721

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7630
by: al | last post by:
Greetings, In the customers table in Northwind db, one can update PK (customerid) and all other fields in the same table. My question is how can you do this in the udpate stat. That is, if one...
1
6121
by: Gent | last post by:
am using FOR UPDATE triggers to audit a table that has 67 fields. My problem is that this slows down the system significantly. I have narrowed down the problem to the size (Lines of code) that need...
2
2502
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
2
5242
by: Niyazi | last post by:
Hi, I have not understand the problem. Before all the coding with few application everything worked perfectly. Now I am developing Cheque Writing application and when the cheque is clear the...
8
3690
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
13
7648
by: abdoly | last post by:
i wrote a code to update datagrid with the datagrid updatecommand but i cant get the updated values after being update that is the code private void DataGrid1_UpdateCommand(object source,...
8
2671
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
1
2511
by: cindy | last post by:
this is the call private void Page_Load(object sender, System.EventArgs e) { OdbcConnection connection = new OdbcConnection ("DSN=PFW52"); CreateDataAdapter(connection); } this is the code,...
5
3045
by: =?Utf-8?B?UlBhcmtlcg==?= | last post by:
I used the wizard to generate a typed dataset for my table and let it create my SPROCs. It created everything, and the GetData() method and the custom GetByUserName query works great, but when I...
11
6041
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
7136
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,...
0
7182
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,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7397
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5490
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,...
0
4611
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...
0
3110
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...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.