|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
I am attempting to access a dBase to either add one item or delete one item. I am getting an error with my connection string: Application Script Error 80004005 Microssoft Jet DataBase Engine 'C:\LogPlot\Tables\Color.dbf' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. The file exists and I have checked the path name. Could something else be causing this problem? Here is my code: I decided to go with an SQL statement because of the simplicity of my operation (to remove one item or add one item). Please let me know if I am going about this the wrong way. I am a newbie with ADO. Set ADOConn = CreateObject("ADODB.Connection") strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & pathname & "; Persist Security Info = False" ADOConn.open strConnect Dim SQL If flag = 1 Then 'delete SQL = "DELETE FROM " & tableName & " WHERE " & ColumnName = SelectedText ElseIf flag = 2 Then 'add SQL = "INSRERT INTO " & tableName & " (" & ColumnName & ") VALUES (" & txtAdd.value & ")" End If Dim RS Set RS = CreateObject("ADODB.Recordset") rs.open SQL,ADOConn, adopenKeyset,adLockOptimistic Set RS = ADOConn.Execute(SQL) rs.close |
|
#2
|
||||
|
||||
|
Try this
Code:
Set Conn = CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & PathName & ";Extended Properties=dBASE IV;User ID=Admin;Password="
If flag = 1 Then
'delete
strSql = "DELETE FROM " & tableName & " WHERE " & ColumnName = SelectedText
ElseIf flag = 2 Then
'add
strSql = "INSERT INTO " & tableName & " (" & ColumnName & ") VALUES ('" & txtAdd.value & "')"
End If
This ensures the sql statement is correct
Response.write(strSql)
Response.End
Conn.Execute(strSql)
Conn.Close
Set Conn = Nothing
You don't use a recordset object when executing INSERT, UPDATE or DELETE statements, as these queries do not return any records. |
|
#3
|
|||
|
|||
|
That worked great, but now I am receiving the error:
Syntax error in Query. Incomplete query clause. I have checked the query and it is: SQL = DELETE FROM "Color Prime" WHERE "Primary" = 'White' here is my code: Dim table, column, text, selText table = Chr(34) & tableName & Chr(34) column = Chr(34) & ColumnName & Chr(34) text = "'" & txtAdd.value & "'" selText = "'" & SelectedText & "'" Dim SQL If flag = 1 Then 'delete SQL = "DELETE FROM " & table & " WHERE " & column & " = " & selText ElseIf flag = 2 Then 'add SQL = "INSERT INTO " & table & " (" & column & ") VALUES (" & text & ")" End If Dim RS Set RS = CreateObject("ADODB.Recordset") MsgBox "SQL = " & SQL ADOConn.Execute(SQL) |
|
#4
|
|||
|
|||
|
You want your completed SQl to look like
Code:
SQL = DELETE FROM [Color Prime] WHERE Primary = 'White' You put square brackets around field and table names that have sapces or special characters in them. It is also not recommended to use spaces (and such) in field and table names. S-
__________________
If you have found a particular post helpful, show your appreciation by adding reputation points to that user by clicking the "scales" image in the upper right had corner of their post. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Problems with Connection to dBase with VBScript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|