Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 31st, 2007, 06:04 AM
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserting data using VB.net and sql express

Hi guys:

I have a little problem with inserting data into my database. I am using a form with two text boxes. when i type data into them and press ok, no data is submitted to my database, and in the same time no error message is promted, which i can't understand why.

I am using the following code which does not come with no errors at all.

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        Dim Objconn As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\ECBInvoicing.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
        Objconn.Open()

        ObjCmd = New SqlCommand("INSERT INTO hotel (HotelName, HotelAddress) VALUES (@HotelName, @HotelAddress)", Objconn)


        ObjCmd.Parameters.Add("@HotelName", Data.SqlDbType.VarChar).Value = txtHotelname.Text
        ObjCmd.Parameters.Add("@HotelAddress", Data.SqlDbType.VarChar).Value = txtHotelAddress.Text


        ObjCmd.ExecuteNonQuery()


        Objconn.Close()

    End Sub


Can anyone help please??

Reply With Quote
  #2 (permalink)  
Old June 6th, 2007, 06:53 AM
Registered User
 
Join Date: Jun 2007
Location: Bangalore, Karnataka, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Bro even i have the same problem if u find solution for this inserting dat into datbase please let me know.. my mail id is jeetsupe@rediffmail.com

Reply With Quote
  #3 (permalink)  
Old June 8th, 2007, 07:54 PM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am also having this problem. I suspect that it has something to do with some sort of access permissions because I can't wite to a database using a data grid table either. Can anyone help us?
Reply With Quote
  #4 (permalink)  
Old June 12th, 2007, 02:24 AM
Kia Kia is offline
Authorized User
 
Join Date: Jun 2007
Location: Sydney, NSW, Australia.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I came accross this problem myself recently and to tell you the truth, I messed around with about 15 things at once and it worked. The problem is that I don't know what in particular was the issue. I'm keen to find out what it might have been.

Does your SQL table have a primary key?
Does your datagrid display and allow you to enter data into the new row at the end of the grid?

Kia
Reply With Quote
  #5 (permalink)  
Old June 12th, 2007, 05:45 AM
Registered User
 
Join Date: Jun 2007
Location: Bangalore, Karnataka, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi kia my table contains primary key...
i havent used data grid.... i using textbox only... this is very simple code eating my brain still i am not able to find any solution... do u have have any solution fo this....

Thank You,
Jeetesh Supe

jeetsupe@rediffmail.com

Reply With Quote
  #6 (permalink)  
Old June 14th, 2007, 05:59 AM
Registered User
 
Join Date: Jun 2007
Location: Bangalore, Karnataka, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi all,
  I have found a solution for this
  I will tell you wat i have done...

i was creating database using Visual Studion IDE.. it creates a folder or store in the projct folder...

try using MAnagement Studio available free of download from microsoft site... download it install it...

create database using this... connection string will be now...

Data Source=.\sqlexpress;Initial Catalog=test;Integrated Security=True

where "test" is database name

i am now able to insert a record... it has worked...
try it it works

if u have any other solution for it please let me know

Jeetesh

jeetsupe@rediffmail.com

Thank You

Reply With Quote
  #7 (permalink)  
Old June 18th, 2007, 08:23 PM
Kia Kia is offline
Authorized User
 
Join Date: Jun 2007
Location: Sydney, NSW, Australia.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ahh... now I remember. I've seen this before aswel. A long time ago I used to use VS05 to create the database and place it in the project folder for me. This seemed to always cause the none insert problem. Its when VS moves the database to the project folder.

I now use either SQL Server Enterprise Manager or opt for VS to place the database in the SQL Server's own data folder. Do not copy the database to the project folder.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Encryption in VB.Net and SQL Server malik_naveed101 ASP.NET 1.0 and 1.1 Professional 0 May 9th, 2008 11:45 PM
inserting XML/ASCII data into SQL using VB.net outcast1881 Other Programming Languages 0 July 20th, 2006 07:39 AM
Transfer Sql data into combobox list vb.net prem54 VS.NET 2002/2003 0 April 5th, 2006 05:04 AM
Accessing a SQL Server Express DB thru VB Express djelavic SQL Server 2005 2 February 21st, 2006 07:53 PM
How to connect SQL Express in VB .NET/win Appli. venkikrao General .NET 0 January 4th, 2006 12:37 AM



All times are GMT -4. The time now is 02:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.