473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

VB.net MS SQL inserts but NOT Updating

I've been working for this for more than an hour
Hope someone helps me.
Here's my code


Expand|Select|Wrap|Line Numbers
  1. Try
  2.  
  3.             Dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\LBHdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
  4.             con.Open()
  5.             cmd.Connection = con
  6.  
  7.  
  8.  
  9.  
  10.  
  11.             'cmd.CommandText = "INSERT INTO tblTires(brandname, treadname, size, purchasecost, unitprice) VALUES('" & cboCompanyname.Text & "','" & txtproductname.Text & "','" & txtsize.Text & "' ,'" & txtpurchaseprice.Text & "','" & txtpriceperunit.Text & "'  )"
  12.             cmd.CommandText = "INSERT INTO tblTires (brandname, treadname, size, purchasecost,unitprice) values(@bN,@tN,@sz,@pc,@up)"
  13.             cmd.Parameters.Add("@bN", Data.SqlDbType.Text).Value = cboCompanyname.Text
  14.             cmd.Parameters.Add("@tN", Data.SqlDbType.Text).Value = txtproductname.Text
  15.             cmd.Parameters.Add("@sz", Data.SqlDbType.Text).Value = txtsize.Text
  16.             cmd.Parameters.Add("@pc", Data.SqlDbType.Decimal).Value = txtpurchaseprice.Text
  17.             cmd.Parameters.Add("@up", Data.SqlDbType.Decimal).Value = txtpriceperunit.Text
  18.             cmd.Connection = con
  19.             Dim ds As New DataSet
  20.             Dim da As New SqlDataAdapter
  21.             Dim sql As String = "SELECT * FROM tblTires "
  22.             da.SelectCommand = New SqlCommand(sql, con)
  23.             da.InsertCommand = cmd
  24.  
  25.             da.Fill(ds, "tblTires")
  26.             da.Update(ds, "tblTires")
  27.  
  28.  
  29.  
  30.  
  31.             cmd.ExecuteNonQuery()
  32.             con.Close()
  33.             MsgBox("Tire Information has been added", MsgBoxStyle.Information, "Success")
  34.             cleartxtboxt()
  35.         Catch ex As Exception
  36.             Throw New Exception(ex.Message)
  37.         End Try
  38.  
  39.  


Don't ask the error cause' there's none.
The problem is it does not Update the records in its database when it's stopped, or run again.
Jan 23 '12 #1
1 1914
Say clearly about your problem. thanks
Jan 23 '12 #2

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

Similar topics

0
by: Bob Kaku | last post by:
I'm trying to create a text editing and updating capability to help someone who wants to maintain content on a web page without having to know any HTML or use a web authoring tool and FTP'ng the...
3
by: Robin Tucker | last post by:
Hi there, I have a database on my test machine that will need to be installed on users machines. I would like to create the database with the given schema on the users machine and also with...
3
by: Viswanatha Thalakola | last post by:
Hello, Can someone point me to getting the total number of inserts and updates on a table over a period of time? I just want to measure the insert and update activity on the tables. Thanks....
2
by: Gene Vital | last post by:
Hi all. I am using Visual FoxPro via ODBC to update records on a 7.3.4 PostgreSql server and it appears that it always uses delete/insert instead of updating the current record. Can this be...
6
by: J Smith | last post by:
After doing some googling through the lists and such, I wasn't able to arrive at a solution for a problem I've run into recently. I've seen mention of similar symptoms, but my case seems different....
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
1
by: Roger | last post by:
Got a GridView control on screen - users can select a record from this and it shows up details of selected record in a DetailsView control. DetailsView control is set to allow Updates & Inserts....
9
by: Freebird | last post by:
Hello everyone ... I've a problem in here, I need to make a 70 000 rows insert, and it's taking a lot more than 30 seconds, my problem is that it will be a script that will work in many...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
1
by: Hansen | last post by:
Hi, I'm making a translation thingie, that contains several languages. One of them is Danish and in one of my update scripts, I've come upon something strange. I have a text containing the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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
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,...

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.