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.Tex t
Dim myOleDbConnecti on As OleDb.OleDbConn ection
Dim insertCommand As String
Dim myConnectionStr ing As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=E:\Lectu re\CS220\Progra m backup 3\Ai Ling Ka Salon System\database \login.mdb;User ID=Admin;Passwo rd=;"
insertCommand = "INSERT INTO tblLogin (username, password) VALUES(desc, itemID);"
myOleDbConnecti on = New OleDb.OleDbConn ection(myConnec tionString)
Dim myOleDbCommand As New OleDb.OleDbComm and(insertComma nd, myOleDbConnecti on)
myOleDbCommand = myOleDbConnecti on.CreateComman d
myOleDbCommand. CommandType = CommandType.Tex t
myOleDbCommand. CommandText = insertCommand
myOleDbConnecti on.Open()
Dim temp_num As Integer
Try
temp_num = myOleDbCommand. ExecuteNonQuery
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
myOleDbConnecti on.Close() Thanks...
15 4103
insertCommand = "INSERT INTO tblLogin (username, password) VALUES(desc, itemID);"
Is this desc and item is an variable of front-end.
because
desc is a key word of back-end for Descending order
you cannot pass that as string
now i change the 'desc' to 'description', the same case happen again...i can't see my record inside the MS Access table... Dim description, itemID As String
itemID = txtItemID.Text
description = txtItemDesc.Tex t
Dim myOleDbConnecti on As OleDb.OleDbConn ection
Dim insertCommand As String
Dim myConnectionStr ing As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=E:\Lectu re\CS220\Progra m backup 3\Ai Ling Ka Salon System\database \login.mdb;User ID=Admin;Passwo rd=;"
insertCommand = "INSERT INTO tblLogin (username, password) VALUES(descript ion, itemID);"
myOleDbConnecti on = New OleDb.OleDbConn ection(myConnec tionString)
Dim myOleDbCommand As New OleDb.OleDbComm and(insertComma nd, myOleDbConnecti on)
myOleDbCommand = myOleDbConnecti on.CreateComman d
myOleDbCommand. CommandType = CommandType.Tex t
myOleDbCommand. CommandText = insertCommand
myOleDbConnecti on.Open()
Dim temp_num As Integer
Try
temp_num = myOleDbCommand. ExecuteNonQuery
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
myOleDbConnecti on.Close()
Is this desc and item is an variable of front-end.
because
desc is a key word of back-end for Descending order
you cannot pass that as string
now i change the 'desc' to 'description', the same case happen again...i can't see my record inside the MS Access table... Dim description, itemID As String
itemID = txtItemID.Text
description = txtItemDesc.Tex t
Dim myOleDbConnecti on As OleDb.OleDbConn ection
Dim insertCommand As String
Dim myConnectionStr ing As String = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=E:\Lectu re\CS220\Progra m backup 3\Ai Ling Ka Salon System\database \login.mdb;User ID=Admin;Passwo rd=;"
insertCommand = "INSERT INTO tblLogin (username, password) VALUES(descript ion, itemID);"
myOleDbConnecti on = New OleDb.OleDbConn ection(myConnec tionString)
Dim myOleDbCommand As New OleDb.OleDbComm and(insertComma nd, myOleDbConnecti on)
myOleDbCommand = myOleDbConnecti on.CreateComman d
myOleDbCommand. CommandType = CommandType.Tex t
myOleDbCommand. CommandText = insertCommand
myOleDbConnecti on.Open()
Dim temp_num As Integer
Try
temp_num = myOleDbCommand. ExecuteNonQuery
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
myOleDbConnecti on.Close()
and you never explain what is the error
1. Go to MS access views
2. copy your query and past it in query view
3. then execute it using “!” symbol
4. I think description is also reserved word of database
and copy the error
just like the above, there is no error message comes out, so i don't know what is the error.
after i run using "!" symbol, also no error.
and you never explain what is the error
1. Go to MS access views
2. copy your query and past it in query view
3. then execute it using “!” symbol
4. I think description is also reserved word of database
and copy the error
just like the above, there is no error message comes out, so i don't know what is the error.
after i run using "!" symbol, also no error.
change the name descreption
it is still the same as before even i have changed the name "descriptio n" to "test1"
note: i only have one table (tblLogin) and one query (qryLogin) in MS Access.
both of them are empty.
change the name descreption
it is still the same as before even i have changed the name "descriptio n" to "test1"
note: i only have one table (tblLogin) and one query (qryLogin) in MS Access.
both of them are empty.
Refer post #2
and you never explain why you are using description, itemID
if this description, itemID is a string value then you should pass query like
insertCommand = "INSERT INTO tblLogin (username, password) VALUES(‘desc’, ‘itemID’);"
Refer post #2
and you never explain why you are using description, itemID
if this description, itemID is a string value then you should pass query like
insertCommand = "INSERT INTO tblLogin (username, password) VALUES(‘desc’, ‘itemID’);"
i think this is wrong,
login name = Descreption ot test1
password = itemID
just check that
i already changed the description to test1.
i use:
- test1 as a name for the txtItemDesc text field value
- itemID refers to the txtItemID text field value, and the ID is not integer, but string.
i pass in the query:
insertCommand = "INSERT INTO tblLogin (username, password) VALUES ('test1', 'itemID');"
Refer post #2
and you never explain why you are using description, itemID
if this description, itemID is a string value then you should pass query like
insertCommand = "INSERT INTO tblLogin (username, password) VALUES(‘desc’, ‘itemID’);"
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Not Me |
last post by:
Hi,
I have a stored procedure, that works perfectly when run from the query
analyser, however if I run it through access vba, (using exec) I get a
runtime error 208: invalid object name '#tmpContact'.
Any ideas why this happens? The temporary table #tmpContact is used in
the procedure, but as I say, it all works fine from the analyser.
Thanks,
|
by: DarthMacgyver |
last post by:
Hello,
I recently wrote a survey application. Each question is very similar.
The first questions gives me a problem when there are multiple people
taking the survey (The Database connection Timed out) I am using the
Data Access Application Blocks as ASP.NET (using VB.NET) and SQL 2000.
In there first question there can be up to 27 answers. So I figured
instead of making 27 different trips to the database I woulc just
concatenate my...
|
by: Jindrich Prchal |
last post by:
Hi there.
We are running DB2 v7.2 for Win NT on Windows 2000 SP3 machine with
poor configuration AMD 1800+, 512MB RAM and usual IDE harddisk. During
tests of migration our batch programmes written in Visual Age
Generator by IBM from OS390 to Win2000 was this machine our test
machine and migrated programmes ran quick enough there. Batch
programmes are generated into C++ code from VaGen 3.1, compiled by
MSVC++ and run on the machine with...
|
by: Bob Dydd |
last post by:
Hi Everybody
I have an Access 2000 db with a setup for inserting images in records.
I am using the image path only with the actual images stored elswhere
on the hard disc. This works perfectly well with all of Microsoft
developer installed on the system.
The problem is when I give this to a user who has NOT got Access 2000,
ie I just give him an installation that installs a runtime, my
frontend/backend and images, an error says that...
|
by: Lyn |
last post by:
I am having a frustrating time trying to do a simple insert of a BMP picture
into a Bound Object Frame using both VBA and the Insert | Object... dialog.
I had a separate post thread going on this and closed it off when I thought
I had resolved the problem, but now I am back at square one. So I thought I
would start afresh with a new post. Here is the problem...
A few months ago, I set up a Bound Object Frame on a form which was tied to...
| |
by: Andrew Banks |
last post by:
I've got the following code as part of a C# web form but am having problems
calling a command. I create a dataset and put some data on the screen. This
works fine. (relevant sample below)
foreach (DataRow row in ds.Tables.Rows)
{
detailsbtn = new LinkButton();
//Assign a unique ID to the details control
detailsbtn.ID = "details" + row.ToString().Replace("-",
String.Empty);
|
by: Surya |
last post by:
Dear All,
I have problem on inserting a record to database..Although it looked
easy.. i have caught up with following issue .. please go ahead and
help me to find solution
I Need to insert records to a data base,for which i am using Typed
dataSet.(I used DataSet Designer to create one)
Then created a table adapter in which i have written query for
INSERT , & set Database Direct property to true.(I didnt use a
seperate methods for...
|
by: Lyn |
last post by:
From time to time I strike a problem where Access will suddenly shut down
while running some code (Dr Watson message), wiping out any forensics
(diagnostic traces such as debug.prints, etc). This is frustrating enough,
but if I step through the same code one instruction at a time, it always
functions perfectly. I have usually resolved the issue by time-consuming
trial and error, making pseudo-random code changes until I end up with...
|
by: AlexanderDeLarge |
last post by:
Hi!
I got a problem that's driving me crazy and I'm desperately in need of help.
I'll explain my scenario:
I'm doing a database driven site for a band, I got these tables for their discography section:
Discography
---------------------
DiscID
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |