473,320 Members | 2,117 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,320 software developers and data experts.

i cant able to insert values using the code

Expand|Select|Wrap|Line Numbers
  1. dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\KarthI\sample\db1\WindowsApplication1\WindowsApplication1\bin\Debug\phm_pharmacy.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
  2. con.Open()
  3.         Dim cmd As New SqlCommand
  4.         cmd.CommandText = "insert into quotation_t11 values('" & TextBox1.Text & "','" & ComboBox1.SelectedItem & "','" & TextBox2.Text & "','" & TextBox3.Text & "')"
  5.         cmd.Connection = con
  6.         cmd.ExecuteNonQuery()
  7.         MsgBox("Insertion process is success")
  8.         con.Close()
  9.  
When i run this code it showing insertion process is sucess but i cant able to see the value inside the table....
created table using microsoft sql database file
Mar 26 '09 #1
2 1371
MrMancunian
569 Expert 512MB
Hi, try this code:

Expand|Select|Wrap|Line Numbers
  1. dim con As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\KarthI\sample\db1\WindowsApplication1\WindowsApplication1\bin\Debug\phm_pharmacy.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
  2. Dim strInsertQuery As String = “insert into quotation_t11 values('" & TextBox1.Text & "','" & ComboBox1.SelectedItem & "','" & TextBox2.Text & "','" & TextBox3.Text & "')" 
  3. Dim cmdInsertCommand As New SqlCommand(strInsertQuery, con) 
  4. con.Open() 
  5. cmdInsertCommand.ExecuteNonQuery()
  6. con.Close()
Steven
Apr 8 '09 #2
aryanbs
42
Try MrMancunian code!

Make sure, the file is not being overwriten by application main folder's mdf, to check that, look in Solution Explorer, your mdf's proerties, copy to output Directory, change it to never

Also Check whether cmd.ExecuteNonQuery() is returning value 1 or not

Dim cnt as Integer=cmd.ExecuteNonQuery()
Messagebox.Show(cnt.ToString())
Apr 8 '09 #3

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

Similar topics

15
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
3
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax:...
10
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
7
by: David Bear | last post by:
I have a dictionary that contains a row of data intended for a data base. The dictionary keys are the field names. The values are the values to be inserted. I am looking for a good pythonic...
4
by: timasmith | last post by:
I guess more the fool me for attempting with MS Access but if I execute select max(nbr) from mytable nextnbr = maxnbr + 1 insert into mytable (nextnbr...) multiple times - it appears the...
3
by: mahajanvit | last post by:
Hi one and all I got this problem during my project. So in order to solve this I made a very small application. I am trying to insert using SP and sqldatasource control. I know that while using...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
6
flexsingh
by: flexsingh | last post by:
Hello there, I have constructed a option of choosing a court only available when member no = "0". This works fine and is in the first code: - <html> <head> </head> <body background="main...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.