Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 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 Display Modes
  #1 (permalink)  
Old July 15th, 2007, 10:51 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yzlin04 Send a message via Yahoo to yzlin04
Default Problem in inserting a new row in MS Access

Hello,
I'm new in vb.net. I have a problem in inserting a new row to a MS Access database table.
There is no error message comes out when i run my program, but when i check my MS Access table, there is no record inserted. So, i don't know which line is incorrect.

Here is my code:

  Dim desc, itemID As String

        itemID = txtItemID.Text
        desc = txtItemDesc.Text

        Dim myOleDbConnection As OleDb.OleDbConnection
        Dim insertCommand As String
        Dim myConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Lecture\CS220\Program backup 3\Ai Ling Ka Salon System\database\login.mdb;User ID=Admin;Password=;"

        insertCommand = "INSERT INTO tblLogin (username, password) VALUES(desc, itemID);"

        myOleDbConnection = New OleDb.OleDbConnection(myConnectionString)

        Dim myOleDbCommand As New OleDb.OleDbCommand(insertCommand, myOleDbConnection)

        myOleDbCommand = myOleDbConnection.CreateCommand

        myOleDbCommand.CommandType = CommandType.Text

        myOleDbCommand.CommandText = insertCommand

        myOleDbConnection.Open()

        Dim temp_num As Integer
        Try
            temp_num = myOleDbCommand.ExecuteNonQuery
        Catch ex As Exception
            Trace.WriteLine(ex.ToString)

        End Try

        myOleDbConnection.Close()



Reply With Quote
  #2 (permalink)  
Old July 16th, 2007, 08:03 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there... you are not receiving any error in the trace window??? you insert code is wrong, you are not sending any values to insert (you are sending something, but they are not string, not even others values..)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #3 (permalink)  
Old July 18th, 2007, 11:11 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yzlin04 Send a message via Yahoo to yzlin04
Default

thanks for the help. now my code works already.
Thanks...:)

Reply With Quote
Reply


Thread Tools
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
Problem with inserting a new row in MS Access yzlin04 VB Databases Basics 0 July 15th, 2007 11:23 PM
having problem in inserting in access database alto ASP.NET 2.0 Basics 4 May 24th, 2007 08:57 PM
problem with inserting images in Access report pankaj_daga Access 1 February 1st, 2007 07:45 AM
Insert row into MS-ACCESS database ITladybug ADO.NET 1 January 28th, 2006 06:57 AM
Problem with inserting data into an Access DB donrafeal ASP.NET 2.0 Basics 0 January 6th, 2006 04:34 PM



All times are GMT -4. The time now is 10:43 AM.


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