Hi, i need to extend my system functionality . I need to do add and edit function. Can anyone help me by guide how to do so ? I got error when i use this coding. -
Dim cn1 As ADODB.Connection
-
Dim rs1 As ADODB.Recordset
-
Dim sqlString As String
-
-
' Add new record -
-
sqlString = "Insert INTO Alternator Engine,Volt,Amp)" _
-
& " VALUES (" & txtAlternator.Text & "," & txtVolt.Text & "," & txtAmp.Text & ")"
-
-
Set rs1 = cn1.Execute(sqlString)
-
-
' Clear the fields -
-
txtAlternator.Text = ""
-
txtVolt.Text .Text = "" txtAmp.Text = ""
4 7228
Your SQL ordering\syntax is wrong.
The SQL syntax is as follows: -
INSERT INTO [TableName] (fieldname,fieldname,fieldname) VALUES ('" & Value1 & "', '" & Value2 & "', '" & Value3 & "')
-
-
Your missing your table identifier. What table those fields are in.
Also, I COULD be wrong, but I don't think you can have a field name in a table with a space in it (Alternator Engine is not a valid name for a column, if you go check your table design I'm betting thats not the name)
So you need something like this instead: -
sqlString = "Insert INTO MyTable (AlternatorEngine,Volt,Amp)" _
-
& " VALUES ('" & txtAlternator.Text & "'," & txtVolt.Text & "," & txtAmp.Text & ")"
-
Also note that I have placed single quote ' around the txtAlternator.Text. This is because that is likely a string data type in your table design. Any string\text data type in a table will need the single quotes around it '" & x & "', if it is a number\integer\long then you just need the " & x & "
Hey there!
You've come to the right place, although I am not too skilled in ADODB. I can post something in DAO that works just great:-)
Add reference to Microsoft DAO 3.06 Object Library -
Private Sub subt_Click() 'this funtion will load entry into database
-
-
Dim my_database As Database
-
Set my_database = OpenDatabase("C:\DataMining\Data_Central.mdb")
-
my_database.Execute "insert into Data_Central.Employee(UserID, EmployeeID, TodayDate, DOB,Title,Fname,Mname,Lname,Suffix, Address1,Address2,City,State,PostalCode,Country,Gender,MaritalStatus,HomePhone,MobilePhone,Fax,Email,LicenseNum,Day,Month,Year,County) Values('" & Text1(0).Text & "','" & Text1(1).Text & "' , '" & Text1(2).Text & "' , '" & Text1(3).Text & "','" & Text1(4).Text & "' , '" & Text1(5).Text & "' ,'" & Text1(6).Text & "' ,'" & Text1(7).Text & "' ,'" & Text1(8).Text & "' ,'" & Text1(9).Text & "' ,'" & Text1(10).Text & "' ,'" & Text1(11).Text & "' ,'" & Text1(12).Text & "','" & Text1(13).Text & "' ,'" & Text1(14).Text & "' ,'" & Text1(15).Text & "' ,'" & Text1(16).Text & "' ,'" & Text1(17).Text & "' ,'" & Text1(18).Text & "' ,'" & Text1(19).Text & "' ,'" & Text1(20).Text & "' ,'" & Text1(21).Text & "' ,'" & Text1(22).Text & "','" & Text1(23).Text & "','" & Text1(24).Text & "','" & Text1(25).Text & "')"
-
my_database.Close ' close the database
-
-
End Sub
-
You probably don't need all of the textboxes I have added...
Have fun:-)
If using adodb then try using this
create a connection object
open the connection -
con.BeginTrans
-
con.execute "your insert statment goes here"
-
'con.execute "your update statment goes here"
-
con.CommitTrans
-
I wanted to view the table of sqlite database in a datagrid or Flexgrid of VB 6.
and allow datagrid for edit and update to the databae.
Here is my code...
But it showed all the table in a single row of flex grid :s
Option Explicit
'// SQL Lite dll declarations:
Private Declare Sub sqlite3_open Lib "SQLite3VB.dll" (ByVal filename As String, ByRef handle As Long)
Private Declare Sub sqlite3_close Lib "SQLite3VB.dll" (ByVal DB_Handle As Long)
Private Declare Function sqlite3_last_insert_rowid Lib "SQLite3VB.dll" (ByVal DB_Handle As Long) As Long
Private Declare Function sqlite3_changes Lib "SQLite3VB.dll" (ByVal DB_Handle As Long) As Long
Private Declare Function sqlite_get_table Lib "SQLite3VB.dll" (ByVal DB_Handle As Long, ByVal SQLString As String, ByRef errstr As String) As Variant()
Private Declare Function sqlite_libversion Lib "SQLite3VB.dll" () As String ' Now returns a BSTR
'// This function returns the number of rows from the last sql statement. Use this to ensure you have a valid array
Private Declare Function number_of_rows_from_last_call Lib "SQLite3VB.dll" () As Long
Private Sub Command1_Click()
Dim dbfile As String
Dim dbquery As String
Dim db As Long
Dim mvar As Variant
Dim mv1 As Variant
Dim errstr As String
Dim row As Long
Dim col As String
Dim mstr As String
Dim i As Long
Dim L1 As ListItem
Dim j As Long
dbfile = App.Path & "\jas.db"
dbquery = "select * from rec2"
If dbfile = "" Or dbquery = "" Then
MsgBox "Query not found:"
Else
sqlite3_open dbfile, db
If db > 0 Then
mvar = sqlite_get_table(db, dbquery, errstr)
row = number_of_rows_from_last_call
row = row + 1
lbl1.Caption = row
If row > 0 Then
For Each mv1 In mvar
mstr = mv1
col = mstr
If i < row Then
DataGrid1.TextMatrix(i, 1) = col
i = i + 1
End If
If i >= row Then
DataGrid1.TextMatrix(i, 2) = col
End If
Next
End If
End If
sqlite3_close db
End If
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hamed |
last post by:
Hello
I have employed as a developer in a software company that its team uses
FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to
migrate to VS.NET. There is a project...
|
by: sedefo |
last post by:
I ran into this Microsoft Patterns & Practices Enterprise Library while i
was researching how i can write a database independent data access layer. In
my company we already use Data Access...
|
by: Manolis |
last post by:
Hi,
I was wondering if there is any way to make two objects of the same
class to be able to access each other's private data, like this:
class A {
public:
void access( const A& a )...
|
by: Neil Ginsberg |
last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC
linked tables. I recently created a new set of tables for the app, and users
are complaining that unsaved data is being...
|
by: Tony Lee |
last post by:
Some time a ago, on this newsgroup the following comments were made in
recommending
good references for Access (2003)
>I used to recommend Dr. Rick Dobson's, "Programming Access <version>" for...
|
by: Lyle Fairfield |
last post by:
In a recent thread there has been discussion about Data Access Pages. It
has been suggested that they are not permitted on many or most secure sites.
Perhaps, that it is so, although I know of no...
|
by: the_grove_man |
last post by:
I guess my question can go in two directions. I create applications
that run multiple queries against a database. Generally speaking in the
past I have used a Data Control (calling it dat1)...
|
by: Johann Blake |
last post by:
I am looking for a good solution on how to implement data access in an
application so that there is a clean separation between the data access
layer, the business layer and the GUI layer. I am...
|
by: TC |
last post by:
I need an automated procedure to copy data from an Access table to a
SQL Server table. Speed is important. What is the recommended
technique?
I can export the data from Access, copy it via FTP,...
|
by: Wesley Peace |
last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having
with visual studio 2008.
I've created a series of forms with controls to access a Access database
tables. The...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
| |