Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> VB.NET & MS Access Issue
Jeigh
post Jul 19 2006, 05:32 PM
Post #1


Whitest Black Mage
Group Icon

Group: [MODERATOR]
Posts: 1,352
Joined: 20-May 05
From: NB, Canada
Member No.: 5,281



Alright, I haven't had much experience with vb.net or ms access as it is, let alone using them together, so I need some advice on the best way to do this.

I need to create a program that basically is a form to fill out with information, and upon filling it out it can be saved. Saving consists of making a row in a ms access database and placing each field as a column entry within this new row. Then I need to be able to retrieve this information from the DB and fill out the form as it was originally if the user chooses to load.

This is all fine and wasn't hard to accomplish BUT that only works properly if I fill out all the fields of the form. Leaving blanks causes it to crash since I'm basically creating an SQL statement with

CODE
quer = "insert into table (field1, field2, field3, field4) values('" & txtfield1.Text & "','" & txtfield2.Text & "','" & txtfield3.Text & "','" & txtfield4.Text & "')"


Now I am not understanding why this happens, since I can manually place either null or blank spaces (as in actual keyed spaces) in the database as entries and it works fine, so I don't see why this would cause a problem this way. I know a work around for this (basically check if each field is empty and then only add it to the sql statement if it is occupied) howevere there are ALOT of fields and this would take alot of monotonous typing to achieve. If anyone knows of a simpler way to do this, it would be greatly appreciated.
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Jul 20 2006, 08:11 PM
Post #2


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411



Your code seems fine - no errors there. Can you attach the project here? Have to see the greater picture to be able to tell.
Go to the top of the page
 
+Quote Post
faulty.lee
post Nov 14 2006, 10:43 AM
Post #3


Premium Member
Group Icon

Group: [HOSTED]
Posts: 495
Joined: 5-November 06
Member No.: 17,016



Did you get any message after it crashed? SQL error?

QUOTE(miCRoSCoPiC^eaRthLinG @ Jul 21 2006, 04:11 AM) *

Your code seems fine - no errors there. Can you attach the project here? Have to see the greater picture to be able to tell.

Go to the top of the page
 
+Quote Post
iGuest
post Jul 25 2008, 12:20 PM
Post #4


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



VB.Net & MS Access Solution
VB.NET & MS Access Issue

Replying to Jeigh
Hie Jeigh. Your code does look alright. But there are two things you probably should look into.

1 - make sure the MS Access table columns for which blank values are possible scenarios allow for "Null" entries
2 - The string values you want to put into the Access database should not have the ' character. This character should be used only as pat of the SQL syntax. You might want to clean the user input and replace the ' characters with something more closely ressembling like `.

Hope this helps ;)

-reply by Seej
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. VB6-MS Access Question(8)
  2. VB.NET / MS Access Question(6)


 



- Lo-Fi Version Time is now: 7th October 2008 - 05:31 AM