Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 17th, 2005, 12:34 PM
sarahjackel sarahjackel is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 sarahjackel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 18 sec
Reputation Power: 0
Question Problems with Connection to dBase with VBScript

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

Reply With Quote
  #2  
Old February 17th, 2005, 12:40 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
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.

Reply With Quote
  #3  
Old February 17th, 2005, 02:45 PM
sarahjackel sarahjackel is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 sarahjackel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 18 sec
Reputation Power: 0
Unhappy That worked...but now I have an Incomplete query clause

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)

Reply With Quote
  #4  
Old February 17th, 2005, 03:25 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 13
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Problems with Connection to dBase with VBScript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT