Click here to Skip to main content
16,006,006 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: how to save a file into MS Access Table... Pin
Nouvand3-Aug-06 21:48
Nouvand3-Aug-06 21:48 
GeneralRe: how to save a file into MS Access Table... Pin
Stephen McGuire4-Aug-06 1:01
Stephen McGuire4-Aug-06 1:01 
GeneralRe: how to save a file into MS Access Table... Pin
Nouvand7-Aug-06 21:07
Nouvand7-Aug-06 21:07 
Questioninsert syntax problem, pls help.... Pin
kyosugi2-Aug-06 23:38
kyosugi2-Aug-06 23:38 
AnswerRe: insert syntax problem, pls help.... Pin
Nouvand3-Aug-06 0:59
Nouvand3-Aug-06 0:59 
AnswerRe: insert syntax problem, pls help.... Pin
Dave Kreskowiak3-Aug-06 1:33
mveDave Kreskowiak3-Aug-06 1:33 
GeneralRe: insert syntax problem, pls help.... Pin
kyosugi3-Aug-06 7:42
kyosugi3-Aug-06 7:42 
AnswerRe: insert syntax problem, pls help.... Pin
Stephen McGuire3-Aug-06 12:38
Stephen McGuire3-Aug-06 12:38 
You have single quotes inside your double quotes. You should only include these for 'string' values. Numbers should not have single quotes. Additionally, 'Date' fields may need octothorpes (#) instead of single quotes.
Your commands are setup a little inefficiently. You should only keep a connection open for the shortest time possible. Do everything else first, then open the connection just before you execute your command, then close immediately.

Try this:

Private Sub AddSubmitB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddSubmitB.Click
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Jasmine\db.mdb"

Dim con As OleDb.OleDbConnection
con = New OleDb.OleDbConnection(strcon)

Dim cmd As New OleDb.OleDbCommand
cmd.Connection = con

Dim strsql As String

strsql = "Insert into member (BorrowerId, password, MemberType, Fname, Lname, Gender, Address1, Address2, Address3, ContactNo, HandPhNo, Email, CourseOfStudy, EnrolledDate, ExpiryDate) values ('" & StudIdTB.Text & "','" & StudPwTB.Text & "','" & UgTB.Text & "','" & StudFnTB.Text & "','" & StudLnTB.Text & "','" & StudGenderCLB.Text & "','" & StudAdd1TB.Text & "','" & StudAdd2TB.Text & "','" & StudAdd3TB.Text & "','" & StudHmTB.Text & "','" & StudHpTB.Text & "','" & StudMailTB.Text & "','" & CosCB.Text & "','" & EnrolledCB.Text & "','" & ExpiryCB.Text & "')"

cmd.CommandText = strsql

con.Open()
cmd.ExecuteNonQuery()
con.Close()

MsgBox("New Member Added!")
Me.Close()

End Sub

I haven't changed any of strsql because you seem to think the query is ok. Only you would know that. Check the single quotes etc are legal..

For queries containing this many fields, you should be using parameter queries. Once you get used to them, you will use them all the time. They are much easier to read and you can check/set data types as you go.

Steve
QuestionTo make characters in the text of TextBox ReadOnly. Pin
Prodigy2012-Aug-06 23:02
Prodigy2012-Aug-06 23:02 
AnswerRe: To make characters in the text of TextBox ReadOnly. Pin
kyosugi2-Aug-06 23:31
kyosugi2-Aug-06 23:31 
GeneralRe: To make characters in the text of TextBox ReadOnly. Pin
Prodigy2013-Aug-06 0:43
Prodigy2013-Aug-06 0:43 
AnswerRe: To make characters in the text of TextBox ReadOnly. Pin
Dave Kreskowiak3-Aug-06 1:31
mveDave Kreskowiak3-Aug-06 1:31 
AnswerRe: To make characters in the text of TextBox ReadOnly. Pin
Stephen McGuire3-Aug-06 7:35
Stephen McGuire3-Aug-06 7:35 
Questioninvoice in data report..? Pin
campbells2-Aug-06 22:52
campbells2-Aug-06 22:52 
Questioncontext menu in listview???(complex)[VB6] Pin
giddy_guitarist2-Aug-06 21:37
giddy_guitarist2-Aug-06 21:37 
AnswerFLASE ALARM Pin
giddy_guitarist3-Aug-06 7:53
giddy_guitarist3-Aug-06 7:53 
QuestionQuestion about Resizing and Manipulating program windows in VB Pin
litestep232-Aug-06 14:34
litestep232-Aug-06 14:34 
QuestionWeird email problem [modified] Pin
eagertolearn2-Aug-06 13:37
eagertolearn2-Aug-06 13:37 
AnswerRe: Weird email problem Pin
Christian Graus2-Aug-06 14:04
protectorChristian Graus2-Aug-06 14:04 
GeneralRe: Weird email problem Pin
eagertolearn3-Aug-06 4:48
eagertolearn3-Aug-06 4:48 
GeneralRe: Weird email problem Pin
VK-Cadec4-Aug-06 5:04
VK-Cadec4-Aug-06 5:04 
AnswerRe: Weird email problem Pin
Dave Kreskowiak3-Aug-06 1:24
mveDave Kreskowiak3-Aug-06 1:24 
GeneralRe: Weird email problem Pin
eagertolearn3-Aug-06 4:50
eagertolearn3-Aug-06 4:50 
QuestionHow to fetch records from sql database in VB.Net Pin
Technobizz2-Aug-06 7:48
Technobizz2-Aug-06 7:48 
AnswerRe: How to fetch records from sql database in VB.Net [modified] Pin
Stephen McGuire2-Aug-06 7:52
Stephen McGuire2-Aug-06 7:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.