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

Insert SQL not working

Hi

Can anyone tell me where I have gone wrong with the following code : it runs
without errors, but does not insert the record in the table!

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim myConnection As SqlClient.SqlConnection
Dim myCommand As SqlClient.SqlCommand
Dim insertCMD As String

myConnection = New SqlConnection _
("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|" _
+ "\Bata_CallInfo.mdf;Integrated Security=True;User
Instance=True")
myConnection.Open()
insertCMD = "Insert into CallLog (AccessCode) values ('18002');"

myCommand = New SqlCommand(insertCMD, myConnection)
myCommand.ExecuteNonQuery()
myConnection.Close()

End Sub
VB.net 2005 Express, SQL Server 2005 Express, Windows XP Professional
"AccessCode" is a field name of type (VarChar(17))

Thanks

Michael Bond
Aug 2 '06 #1
1 1023
Hi

ignore this question ...... there is nothing wrong with the code ......

I did not realise with vb.net 2005 I had to contend with "design time" and
"run time" copies of the databse .......

Not to worry, I'm really quite pleased. I've been using these discussions
groups for 3-4 years and have received much valuable help ..... and this is
the first time Ive answered a posting (even if it is my own!!!)

"mabond" wrote:
Hi

Can anyone tell me where I have gone wrong with the following code : it runs
without errors, but does not insert the record in the table!

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim myConnection As SqlClient.SqlConnection
Dim myCommand As SqlClient.SqlCommand
Dim insertCMD As String

myConnection = New SqlConnection _
("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|" _
+ "\Bata_CallInfo.mdf;Integrated Security=True;User
Instance=True")
myConnection.Open()
insertCMD = "Insert into CallLog (AccessCode) values ('18002');"

myCommand = New SqlCommand(insertCMD, myConnection)
myCommand.ExecuteNonQuery()
myConnection.Close()

End Sub
VB.net 2005 Express, SQL Server 2005 Express, Windows XP Professional
"AccessCode" is a field name of type (VarChar(17))

Thanks

Michael Bond
Aug 2 '06 #2

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

Similar topics

3
by: xMANIGHTx | last post by:
I'm new to DTS. I read some docs before adventuring into this matter. I still haven't found in all the docs I read if there is some "built-in" DTS task or function or wathever, to do a mixed...
7
by: iqbal | last post by:
Hi all, We have an application through which we are bulk inserting rows into a view. The definition of the view is such that it selects columns from a table on a remote server. I have added the...
6
by: efgh | last post by:
I'm fairly confident in my knowledge of SQL but I'm stumped with regards with an Insert Into statement in Access 2003. I've got a 4 column table that I've simplified about as much as I can, no...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
0
by: nsitnikov | last post by:
Hi, Here is the problem that I'm trying to solve. I have a DetailsView on the page, which is set to work in Edit Mode. On insert it adds a record to SQL Server 2000 database. Everything is working...
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...
3
by: Dilruba | last post by:
asp, vbscript, Ms Access I am using vbscript to insert & update ms accees. Insert operation is working , but update operation is not working. I have used the following codes: ...
4
by: LouiseR | last post by:
I just recently tried to use a multi-row insert on a table that contains a timestamp column, but I get SQLCODE -180 even though I'm positive that the value that I'm trying to insert is correct. The...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
4
by: =?Utf-8?B?RXJpYyBGYWxza2Vu?= | last post by:
We’re storing our main entity in an insert only table which stores the history of past revisions, but we’re facing problems with storing this history as LINQ will only update the entity, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...

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.