|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Unable to extract data from ms access
hi guys, i'm using ms access as my database and i can't seem to extract my data from a form that i've jus keyed in ... how is it so?it seems like my database is not updated yet. how can i do so? thanks.
|
|
#2
|
||||
|
||||
|
you could not be more vague.
what code you're using? what you mean "from a form"? if it's not ordinary database table, you can read it only via Access tools not with SQL statements. "database not updated" - if you see the data, restart your computer and still see the data - it's updated. |
|
#3
|
|||
|
|||
|
hi,
sorry for being vague. i'm doing a program using vb, trying to get users to enter inputs such as name, x-coordinate, y-coordinate and store these values into my access database using the following codes: Private Sub btnadd_Click() Dim cn As ADODB.Connection Dim cmd As ADODB.Command Dim rs As ADODB.Recordset Set cn = New ADODB.Connection Set rs = New ADODB.Recordset cn.ConnectionTimeout = 10 cn.CommandTimeout = 10 cn.Provider = "Microsoft.Jet.OLEDB.4.0" cn.Open App.Path & "\dbanchorage.mdb", "admin", "" SQL = "INSERT INTO tblCoordinates (name,x,y) VALUES ('" & txtname.Text & "','" & lblx2.Caption & "','" & lbly2.Caption & "')" Call Sub executeSQL(SQL) End Sub Private Sub executeSQL(SQLCommand As String)Set cmd = New ADODB.Command cmd.ActiveConnection = cn cmd.CommandText = SQLCommand cmd.Execute Set cmd = Nothing End Sub The above codes doesn't seems to have a problem as my db is getting and storing the values correctly. The problem is if i do the following my program doesn't seems to find any datas in my db even though i've keyed in say 3 sets of values already; my lstx will not display anything: SQL= "SELECT * FROM tblCoordinates WHERE name = '" & txtname.Text &"'" rs.Open SQL, cn, adOpenDynamic Do Until rs.EOF lstx.AddItem rs!x rs.MoveNext Loop rs.Close Set rs=nothing I've tried to change my SQL to WHERE name = "name1"; name1 being an old data stored previously; i'm able to display the x values i want properly. how is this so? thanks in advance |
|
#4
|
||||
|
||||
|
what happens when you select all records?
Code:
SQL= "SELECT * FROM tblCoordinates" also, have debug code to show you the SQL: Code:
SQL= "SELECT * FROM tblCoordinates WHERE name = '" & txtname.Text &"'" MessageBox(SQL) rs.Open SQL, cn, adOpenDynamic |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Unable to extract data from ms access |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|