VB6 + SQL Server Error: Can't Update. Database Or Object Is Read Only.
Hi,
I'm hoping someone can help.
I'm using a DAO recordset and SQL Server database (not a great combination).
In any case, on some PCs (not all), sometimes when the AddNew command is run, the application throws the error 'Can't update. Database or object is read only'.
The commands to open the recordset are:
set myrecordset = db.openrecordset(sqlstatement) myrecordset.lockedits = false
Then the line that fails is: myrecordset.addnew
Does anyone have any ideas what could be causing this?
Thanks!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Error - Cannot Update. Database Or Object Is Read Only
I am taking over a Access 2000/SQL 2000 application. I have added a field to the SQL 2000 database and have tried to refresh the links in the Linked Table Manager to get the new field into my Access 2000 application. Now when I run the application I get "Cannot Update. Database or object is read only" and the application wont run. I can go back to a version before I did refreshed the links and the application works (in other words the code hasn't changed between the two versions)
Any ideas on why Access is reporting this error only AFTER i refresh the links?
ASP - Cannot Update. Database Or Object Is Read-only
I cant seem to figure out this error. I am trying to update a local Access database and I keep getting this error. I have only writen the code to update one field since I wanted to test it first. I would really appreciate it if someone could help me figure this out.
The Error Returned Is:
Error Type:
Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.
/childsafe/updateReg.asp, line 28
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)
Page:
POST 324 bytes to /childsafe/updateReg.asp
POST Data:
registrationID=13&child_fname=Jim&child_lname=Jones&parent_fname=Bane& parent_lname=McBain&phone=8135126&street=9384+Mercury+Lane&city=Regina &province=ON&postal=S5F8H6&age=10&contact_fname=same+as&cont . . .
AND HERES THE CODE:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<!-- #include file="adovbs.asp" -->
<!-- #include file="conn.asp" -->
</head>
<body>
<%
set rs_reg = Server.CreateObject("ADODB.recordset")
newln = vbCrLf
strRegistrationID = request.Form("registrationID")
response.write strRegistrationID
SQL = "select child_fname from registration where registrationID="&strRegistrationID
rs_reg.open SQL, objConn, adLockOptimistic, adCmdTable
if rs_reg.eof then
rs_reg.addNew
response.write "NO MATCHING REGISTRATION"
end if
rs_reg("child_fname") = request.form("child_fname")
rs_reg.update
rs_reg.close
%>
</body>
<!-- #include file="close_conn.asp" -->
</html>
Cannot Update. Database Or Object Is Read-only
I use the following code to import the text data into a MS Access 97 database.
Code:
Public Sub DataImport(MyDataFilePath As String, MyDatabaseName As String, MyOverwrite As Boolean)
Dim MyTableName As String
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
' Set the temporary table name as the name of file being imported
MyTableName = fso.GetBaseName(MyDataFilePath)
' Use the TransferText method of Access for importing text data
Dim accApp As Access.Application
Set accApp = New Access.Application
accApp.OpenCurrentDatabase App.Path & "database" & MyDatabaseName & ".mdb", True
accApp.DoCmd.TransferText acImportDelim, "Default Import Specification", MyTableName, MyDataFilePath, True
But the VB blames that:
"Error 3027. Cannot update. Database or object is read-only."
But I have been successful some time before but I dun know what have I changed to make this failure out!!
Do you know what's happening with me? Please help me if you have ideas. Thanks a lot.
Can Not Update. Database Or Object Is Read Only
I get this message when I try to print some bar codes. It copie everything to the files, put brings the error up so it won' print. Is there anyone that can help me find the error? might just be over looking the little error because I'm lookin to hard.
Here is the code.
Thanks
WAFS1801
Option Compare Database
Option Explicit
'
Can't Update. Database Or Object Is Read-only
I am trying to test the update method and I am getting the error Can't Update. Database or object is read-only.
I am using
- Access 97
- rsObj.Open strQuery, connObj, adOpenKeyset, adLockOptimistic, adCmdText
- With rsObj
!Requester_First_Name = frmLogs.txtFirstName.Text
.Update
End With
I appreciate the help.
Can't Update. Database Or Object Is Read-only
hi
I've come to a problem with the following scenario:
VB 6.0 SP 5
ADO (Microsoft ActiveX Data Objects 2.5 Library)
MDAC 2.6
I would like to show data in a grid and to update this data. The data is the result of a left join from 2 tables.
It's no problem to do so as long as I use Cursorlocation = ClientSide. But I would like to use ServerSide. After a very long time of trying I've figured out that I can update my recordset as long as I don't use DISTINCT in my SQL-Statement.
My question is, is there a possibility to have the same effect as distinct has without loosing the ability to update the recordset. I've tryed GROUP BY but it doesn't work either.
Any help would be appreciated
Schweiger
&"Can't Update. Database Or Object Is Read-only&"
I get this when trying to execute something like this... (In vb6 with odbc 3.51)
Code:
Private Sub Command1_Click()
'This is for adding records in table
Set rs = conn.OpenRecordset("TestTable")
With rs
rs.AddNew
rs!Name = Text1
rs!Address = Text2
rs.Update
MsgBox "Record saved!!", vbInformation
End With
Command2_Click 'refresh listview
End Sub
And i get "Can't update. Database or object is read-only"...
I searched google, and from common sense, I need to have attriubtes set to a file/folder? But which one?
Im running windows 2k pro, service pack 4.
Help would be appreciated,
Josh.
&"cannot Update. Database Or Object Is Read-only&"
So, I have a working access .mdb which has linked tables to a sql 2000 database. In the interest of testing a current bug, I copied the database in 2000 so that I had a test db and then I copied the .mdb to another server and built an odbc link pointing to the new database and refreshed the linked tables so that they are pointing at the correct database. When I run the application, the error message I get when it tries to set a value in a recordset is:
"cannot update. Database or object is read-only"
Now, the code was working just fine in production, so it must be related to the copying and migration. In addition, if I go into one of the linked tables, I can view the data, but I can't add a new record and if I try to edit an existing record it says "The recordset is not updateable".
Any ideas on what I am missing??
To err is human. To really foul things up requires a computer.
How Can I Update A Table In SQL Server From A Dataset Object Created From Access
I have no problem creating a dataset using the dataAdapter object. The problem is that all of the documetation provided opens a dataset updates it and inserts back into the same database. I am merely trying to open a dataset in Access, then inserting that dataset into a SQL Server table of the same name and and structure. Here is my code.
Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
Dim cn As New OleDb.OleDbConnection(AuditConnString)
Dim cn1 As New OleDb.OleDbConnection(OledbAuditSQLConnString)
Dim cmd As New OleDb.OleDbCommand()
Dim cmdInsert As New OleDb.OleDbCommand()
'The SQL string will fill one table in SQL Server as opposed to three tables for reporting purposes
Dim sql As String = " Select * from tblReportFindingsFCAudit where upload_status = 0" & _
"Select * from tblReportFindingsBRRAudit where upload status = 0"
Dim SQLInsert As String = "Insert into [tblReportFindingsFCAudit] " & _
"(RepName,Auditor,Audit_Date,FindingsNumber,original_sent_date,second_letter_date,third_letter_date,close_date,upload_status,CheckState) " & _
" VALUES (?,?,?,?,?,?,?,?,?,?)"
cn.Open()
'Create a data adapter that reads and writes the tblFCFindings table
Dim da As New OleDb.OleDbDataAdapter(sql, cn)
Dim dsAccess As New DataSet()
Dim daInsert As New OleDb.OleDbDataAdapter(SQLInsert, cn1)
'Create the dataset
'Read the tblReportFCFindings into a local DataTable
da.SelectCommand = New OleDb.OleDbCommand(sql, cn1)
da.Fill(dsAccess, sql)
daInsert.SelectCommand = New OleDb.OleDbCommand(SQLInsert, cn1)
pcInsert.Add("RepName", OleDb.OleDbType.VarChar)
pcInsert.Add("Auditor", OleDb.OleDbType.VarChar)
pcInsert.Add("Audit_Date", OleDb.OleDbType.Date)
pcInsert.Add("FindingsNumber", OleDb.OleDbType.VarChar)
pcInsert.Add("original_sent_date", OleDb.OleDbType.Date)
pcInsert.Add("second_letter_date", OleDb.OleDbType.Date)
pcInsert.Add("third_letter_date", OleDb.OleDbType.Date)
pcInsert.Add("close_date", OleDb.OleDbType.Date)
pcInsert.Add("upload_stats", OleDb.OleDbType.Boolean)
pcInsert.Add("CheckState", OleDb.OleDbType.Boolean)
daInsert.Fill(dsAccess, SQLInsert)
da.Fill(dsAccess, "tblReportFindingsFCAudit")
'Update Access Database so no duplicates make it into SQL Server
'Dim sql1 As String = "Update tblReportFindingsFCAudit Set upload_status = -1"
'cmd.Connection = cn
'cmd.CommandText = sql1
'Dim records As Integer = cmd.ExecuteNonQuery()
' Debug.WriteLine(records)
'close the connection
cn.Close()
cn1.Close()
End Sub
Update Database On A Web Server
I would like to enter some records offline into an access database and tehe connect to the net using dial-up and update the records on the webserver. How do i establish a connection to the database on the web server ?
Update Database From Web Server
I need advise on this problem:
I have an Access database on a local PC and one on a Web Server (host site). I need to update the local DB with the data which resides on the server.
Should I though ASP, send the new data to local DB or should I from VB (local) retrieve the data and insert into the local DB.
If need be, I can write in any language or script.
I don’t like signed posts, why? We are so used to them that we ignore the last line of the post.
Update Database On A Web Server
I would like to enter some records offline into an access database and tehe connect to the net using dial-up and update the records on the webserver. How do i establish a connection to the database on the web server ?
Using VB To Update Server Database Using Internet
I need a push in the right direction here. I'm using Access databases using both DAO and ADO as needed.
I keep bowling scores for all my bowling leagues on a large (15-20 Mb) database. I update this database nightly. I have been FTPing the entire database to my web server each day so it can be accessed using .asp pages for my bowlers. It's not a big thing, but I've seen apps that check web databases and I thought it would be cool if I could write something that checked the added records on my client machine, connected to the webserver and added these records to my web database using VB. It would even be better if I could query my web database for the last sent records and tell my app this so I could send the appropriate updates.
I've been a VB guy for 20+ years and have never given winsock or such a look. Where would you folks start your learning process if you needed to design such an app? I've always got a programmers book under my nose but I'm buffaloed as to where to start my reading on this one.
Thanks in advance to all
Mark
Edited by - EggmanRC on 8/13/2006 4:31:35 PM
Update A Picture Into Sql Server Database.
In SQL Server, Northwind database, Categories table has a column "Picture", that column type is image. I think that all picture is update into data by binary type.
But I don't know how to display that data into a real picture in VB form, And I also can't update a picture into database when I choose a picture from my application.
Hope to hear from you soon.
Database Or Object Is Read Only
An Access 2000 application has suddenly ceased to function properly on a workstation where, previously, it had no problems.
The error message (in the subject) is returned when attempting to import a fixed legth text file (having an extension other than .TXT) either manually or with the .TransferText method. If I change the extension to .TXT, then all works as planned.
The file(s) and database are not marked as read-only, and the application runs as expected on other workstations. I've already repaired and then re-installed Office 2000 to no avail. If memory serves me properly, I encountered this problem when upgrading from Office 95 to 97 years ago, but I can't remember the resolution.
Database Or Object Read Only.
I'm having a problem adding a new record to my MySQL database.
I have a database called tblLog (Currently empty) with 3 fields: ClientID, ProductID and SecurityID - all varchar
All I want to do it add a new record, but the I keep getting the following error message:
"Run-time error '3027'" "Cannot update. Database or object is read-only."
I'm quite new to mySQL and connecting databases through VB6 (I Usually write all database applications with MS Access)
I'm sure I have set all the access rights/grant permissions correctly.
Below is a cut down version of the code, but the error occures on the rs.addnew command.
Any help would be gratefully received.
private sub InsertNewRow
Dim ws As Workspace
Dim db As Database
Dim rs As Recordset
Dim strConnection As String
strConnection = "ODBC;DSN=softwarelicense;UID=shane;PWD=frogger"
Set ws = CreateWorkspace("ODBCWorkspace", "", "", dbUseODBC)
Set db = ws.OpenDatabase("", False, False, strConnection)
Set rs = db.OpenRecordset("Select * from tblLog", dbOpenDynaset, dbExecDirect, dbOptimisticValue)
rs.AddNew
rs!ClientID = "Cli-0001"
rs!ProductID = "0123"
rs!SecurityID = "97661"
rs.Update
rs.Close
Set rs = Nothing
End Sub
Shane Brennan
'-----------------------
' Emails: shanebrennan@postmaster.co.uk
Add,update/delete Records From SQL Server Database
I have a form where the user inputs around 50 instances of the same type (like 50 member ids) and these have to be stored in a SQL server database. Could anyone please let me know which control would handle this more effectively? This control should also provide for updation and deletion of member ids.
To be more clear, these 50 instances have a key member id. One record is stored in the database for each instance. So if there are 10 member ids connected to this key member id, 10 records are stored in the database. I have a text box on the form where the key field is entered. When the key field is entered, all the available instances from the database for the key member id should be displayed on the form. I should be able to update, delete member ids. All these can be handled using datagid but I also want to insert more member ids. Could anyone please help me with this?
How To Update Record Faster In SQL Server Database Using VB
My application consists of a comand button whereby when the user clicks it, it will update 3 columns in a table in SQL Server Database. At one click, 100 rows in the table will be updated. The rows are updated but anyhow the updating process is very slow, i.e. takes about 2 minutes to update. Would like to seek any help for it to update much faster. My ADO is connecting through ODBC linked to the SQL Server database. My code looks like this :
h = Text1.Text
Text2.Text = Format(Date, "YYYY-mm-dd")
While Adodc1.Recordset.EOF <> True
If Adodc1.Recorset.Fields("Lot_Number") <> h
Adodc1.Recordset.MoveNext
Else
Adodc1.Recordset.Fields("Lot_Code") = "DONE"
Adodc1.Recordset.Fields("Lot_Status") = "COMPLETED"
Adodc1.Recordset.Fields("Time_Stamp") = Text2.Text
End If
WEnd
Appreciate any help on this. Thanks.
Update Two Databases(local And Server Database)
hi..
i wanna know, is it practical to update the local database(MS Access) and server database(MySQL) simultenously? or i need to update only Access database and export to MySQL( in LAN environment)? i'm using MyODBC connector to connect with MySQL 5. how to write codes in VB6 to export the updated local database to MySQL server? i'm using ADO.
Update SQL Server Database From Vba Code (SEEK Or FIND)
(Access 2000 project/SQL Server database)
I'm trying to figure out the quickest way to update records in a SQL Server database via code. The User inputs data on a daily basis and upon exitting from the data entry form, a module is called that selects data from the file and recalculates a field value based on summarized records. Currently I have a stored procedure that selects the records requiring recalculation and stores summarized values on each record for the calculations. Following is my code:
Set Rst2 = New ADODB.Recordset
Rst2.Open "tblTest", Comm1, adOpenKeyset, adLockOptimistic, adCmdTable
Cmd1.ActiveConnection = Comm1
Cmd1.CommandText = "sp_Test"
Cmd1.CommandType = adCmdStoredProc
Set Parm1 = Cmd1.CreateParameter("@ZStartDate", adDate, adParamInput)
Parm1.Value = ZStartDate
Cmd1.Parameters.Append Parm1
Set Parm1 = Nothing
Set Rst1 = Cmd1.Execute()
If Rst1.EOF Then
Rst1.Close
Set Rst1 = Nothing
Exit Function
End If
Rst1.MoveFirst
While Not Rst1.EOF
..... calculations
Rst2.MoveFirst
Rst2.Find "ID = " & Rst1!ID
If Rst2.EOF Then
Else
Rst2!TestValue = NewValue
Rst2.Update
End If
Rst1.MoveNext
Wend
I'm thinking it would be quicker to just update the Rst1 recordset except that I have the summarized fields stored on each record making it non-updateable. Any help would be appreciated. Thanks.
READ DATA FROM XML FILE TO SQL SERVER DATABASE
HI,
ANY ONE CAN U TELL ME HOW TO READ DATA IN XML FILE TO SQL DATABASE BOTH SQL SERVER DATA BASE AND XML FILES ARE IN WEB SERVER I WANT TO DO THIS IN CLIENT USING VB PROGAMMING OR USING ASP
THANX,
MANJULA
READ DATA FROM XML FILE TO SQL SERVER DATABASE
HI,
ANY ONE CAN U TELL ME HOW TO READ DATA IN XML FILE TO SQL DATABASE BOTH SQL SERVER DATA BASE AND XML FILES ARE IN WEB SERVER I WANT TO DO THIS IN CLIENT USING VB PROGAMMING OR USING ASP
THANX,
MANJULA
Error - Method 'Update' Not Supported By Automation Object
Hi i am sending a range of text from excel to outlook successfully the first time through. if i attempt to send again (without closing and reopening the spreadsheet) i get an error at the Send command
Run-time error '-2147418113 (8000fff)': Method 'Update' not supported by automation object
i use redemption - my code is fairly simple
Dim SafeItem
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance of Redemption.SafeMailItem
With ActiveSheet.MailEnvelope
SafeItem.Item = .Item
SafeItem.Recipients.Add ...
Range("AR50:AT92").Select
SafeItem.Send
...
Set SafeItem = Nothing
i stuck this in at the end
Set Utils = CreateObject("Redemption.MAPIUtils")
Utils.Cleanup
but it still happens
anyone have any ideas?
thanks.
Edited by - sbcosmo on 1/27/2006 7:36:29 AM
Error Trying To Update Database
Hi All,
I'm getting a annoying problem i just cannot get my head around
when i try to run the code i get this error
[Informix][Informix ODBC Drive][Informix] Missing key in referenced table for referential constraint
Code:
strSql = "UPDATE workrqst SET batch_no = 1 WHERE record_seq = '" & adoRec.Fields.Item("record_seq").Value & "'"
g_cn.Execute (strSql)
adoRec is a RecordSet i had previously opened
Any ideas
VB Error When Try To Update Database
hi...i have everything installed correctly but when i fill customer form in the customer table,error like this come out.
compiler error: variable not defined
n the blue color code down here being highlighted when error come out.
Private Sub Command1_Click()
help me please.....here my code in the form9.frm of registration form.
Code:
Option Explicit
Public conn As ADODB.Connection
Public Function SetConnection(m_con As String) As ADODB.Connection
On Error GoTo ErrorTrap
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.CursorLocation = adUseClient
conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
& "SERVER=localhost;" _
& "DATABASE=e-trusty;" _
& "UID=root;" _
& "PWD=rocklynda;" _
& "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
conn.Open
Set SetConnection = conn
ExitPoint:
Exit Function
ErrorTrap:
Set SetConnection = Nothing
MsgBox "You must be Connected to the MySql server before using this system"
Resume ExitPoint
End Function
[color=Blue]Private Sub Command1_Click()[/color]
Set conn = SetConnection(customer.Text)
conn.Execute "Update " & customer.Text & " Set cust_id= '" & Text1.Int & "'"
conn.Execute "Update " & customer.Text & " Set cust_name= '" & Text2.VarChar & "'"
conn.Execute "Update " & customer.Text & " Set cust_add= '" & Text3.VarChar & "'"
conn.Execute "Update " & customer.Text & " Set cust_phone= '" & Text4.VarChar & "'"
MsgBox "Your info has been saved to our Customer Database"
End Sub
Database Update Error.
"Insufficient base table information for updating or refreshing"
This happens each time I try to update my database, I am using a data enviroment connection and Jet 3.1. I notice this happens when I am running on Windows XP.
Update IBM DB2 Database Error . Pls Help !
I'm using Visual Basic 6.0 to update a DB2 database.
As I know we can either use .Addnew method of an ADO Recordset object or SQL INSERT statement to Insert a new DB2 record.
I have definied a table in DB2 with a field name "FLDERROR" having the data type "Long VARCHAR"
By using .Addnew method, part of my VB coding is as follows :
adoRecordSet.AddNew
adoRecordSet!FLDCUSTID = "1"
adoRecordSet!FLDADDR = "NEW YORK"
adoRecordSet!FLDAGE = "18"
adoRecordSet!FLDGRADE = "01"
adoRecordSet!FLDERROR = "ABC"
when I run the program, the program ends in error at the last statement above and prompts the message :
Run-time error '-2147467259(80004005)':
CLI0100E Wrong number of parameters. SQLSTATE = 07001
Do anyone can help what's wrong with that ? I didn't hit any error when updating "Character" / "VARCHAR" field in DB2 by using the same method.
Asp, Classic. Database Update Error.
hey, i have this assignment.
I worked on it @ uni and it was working fine.
Its a simple post form details into a access database script
code =
***********
Code:
<%@ language=VBscript %>
<% Option Explicit %>
<!-- #include virtual="/ianweb/adovbs.inc" -->
<HTML>
<body>
<%
'open a connection to our access database
'we will use a DSN-less connection.
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=c:inetpubwwwrootianwebianspies.mdb"
objConn.Open
Dim objRS
Set objRS = Server.CreateObject ("ADODB.Recordset")
objRS.Open "spies", objConn, adOpenStatic, adLockOptimistic, adCmdTable
'Create a recordset object instance and retrieve the
'information from the friends table tblFriends
objRS.AddNew
objRS("firstname") = Request.Form("firstname")
objRS("middlename") = Request.Form("middlename")
objRS("surname") = Request.Form("surname")
objRS("street") = Request.Form("streetaddress")
objRS("town") = Request.Form("town")
objRS("postcode") = Request.Form("postcode")
objRS("sex") = Request.Form("sex")
objRS("age") = Request.Form("age")
objRS("eyecolour") = Request.Form("eyecolour")
objRS("sugardaddy") = Request.Form("sugardaddy")
objRS("sugarmommy") = Request.Form("sugarmommy")
objRS.Update
objRS.close
objConn.close
%>
<body>
Thanks
</body>
</html>
*************************
The error i get is
*************************
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.
/ianweb/addafriend.asp, line 39
**************************
which is the line with the
objRS.Update command in it.
can somene tell me if its a IIS issue im having, a O/S permissions thing or a code thing?
if so, can you give me a clue on how to fix it?
cheers
Database Update Run-time Error
Does anyone know what a
"Run-Time Error '-2147217887 (80040e21)': Errors Occurred" means? I'm trying to update a SQL Server database thru VB6 with an ADO recordset and it seems to work most of the time I try to add records, except for one certain record. Any help would be greatly appreciated!
Default Date Problem With VB Object And SQL Server Database
I am working on VB 6 and SQL Server 7.
I have an object with different data types and one among is date type. I have a stored procedure with all fields as parameters to update a table. The problem is if I don't set any date to my date variable in the object while saving, it is inserting 01/01/1900 as date. I think it is the default date in VB. If I don't set date, I should only insert NULL value to the database. What are the alternatives.
Its weird when I check the following code
Dim tDate as Date
debug.print isNull(tDate) --> this always return false
Using ADO To Read A Blob Object And Save It To A Gif File But Error Throw
Hi , i am using this Microsoft ActiveX Data Objects 2.5 Library for the References
The purpose of the function is to retrieve from a blob object and save it to image file eg. gif or jpeg and store into a directory eg. C:images
-----------------------------------------
Option Explicit
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
Private Sub Command1_Click()
Dim sQuery As String
Dim sFileName As String
On Error GoTo Command1_Error
Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB;data Source=KARENTANPC; Initial Catalog=UserProfile;User Id=sa;Password=pass"
Set rs = New ADODB.Recordset
sQuery = "SELECT FileName,image FROM User"
rs.Open sQuery, cn, adOpenKeyset, adLockOptimistic
While Not rs.EOF
Set mstream = New ADODB.Stream
mstream.Type = adTypeBinary
mstream.Open
'Define the location of the image to be output
sFileName = App.Path & "" & rs.Fields("FileName") & ".gif"
mstream.Write rs.Fields("image").Value
Debug.Print sFileName
If Len(sFileName) <> 0 Then
mstream.SaveToFile sFileName, adSaveCreateOverWrite
End If
rs.MoveNext
Wend
rs.Close
cn.Close
MsgBox "Done saving image from database to " & App.Path
Command1_Error:
MsgBox Str(Err) & " - " & Error, vbExclamation
End Sub
'*************************************************************
Error Throw I Keeping getting the ADO Error message stating 3001 - Arguments are of the wrong type , out of acceptable range , or are in conflict with another
when i compile , i tried to lookup the error source but it seems that my SQL statement is correct , there is not problem with my sql statement
'***************************************************************
Can't Update Informix Database - 3146 Error
I have a Access database that is linked into an Informix database. In the linked Access database, I have a query setup. In my VB code I reference that query using an OpenDatabase command. Basically I just need to edit to fields and correct some data that is wrong. I can issue the .EDIT command, but when I try to do an .UPDATE I get the 3146 error saying that my ODBC call failed. Upon further investigation into the issue, the actual error that I am gettin is :
A SERIAL column (auto_key) may not be updated
I know I am not doing anything with the auto_key field. I did notice that it is one of two primary keys, however, the other primary key is listed before auto_key and it doesn't error out on that. Any ideas? I have included the whole program below.
[code]
Private Sub cmdchange_Click()
Dim permits As Database
Dim permitsq As Recordset
Dim curparcel, temp As String
Set permits = OpenDatabase("T:linked database.mdb", False, False)
Set permitsq = permits.OpenRecordset("Find duplicates for informix_par_peo")
permitsq.MoveFirst
Do Until permitsq.EOF
curparcel = permitsq!parcel_no
permitsq.MoveNext
If permitsq!parcel_no = curparcel Then
permitsq.MovePrevious
permitsq.Edit
permitsq!relationship = "PREVOWNER"
permitsq!primary_name = "2"
permitsq.Update
ElseIf permitsq!parcel_no <> curparcel Then
permitsq.MovePrevious
permitsq.Edit
permitsq!relationship = "OWNER"
permitsq!primary_name = "1"
permitsq.Update
End If
permitsq.MoveNext
Loop
temp = MsgBox("Done", vbOKOnly, "Done")
End Sub
How To Specify Database Server Or Connection String In A Crystal Report Object
Hi,
In Visual Basic how can I specify the
database server (or connectionstring)
of a crystal report object at runtime?
I need this because the .exe applications
in terminal computers are trying
to load a crystal report which
database resides in server "(local)"
(obviously because I designed the
report in the server and compiled
the visual basic .exe there too)
Thanks a lot for your help
Roland
VB6 Refresh Error After Failed Update On Access Database
Using VB6 and Access 2000 database I have a problem after a failed updaterecord. I get error 524 "can't update because it would cause a duplicate record" type error after I execute a data1.updaterecord,
that's fine...
But after traping this error and continuing on with the program, when I do a data1.refresh I get this error "Method not applicable in this context (Error 444)", "You cannot use this method in the current event procedure" and the program stops. Refresh and update work fine before this update error.
My problem is I need to get the datacontrol.recordset back to what it was before the failed update so I can do data1.refresh in the program when I need to.
It may have something to do with a buffer, locked page, I don't know. I tried data1.recordset.cancelupdate, data1.updatecontrols, closing and reopening the data1 control recordset, but none of these fix it. If I used a SQL update method instead, would that have the same result? Can anyone help?
Thanks,
FRVP
Error In Creating A Server Object From Custom Activex Dll
I have written an ActiveX dll to perform some work. At the top of my ASP script I place the following line.
<!--METADATA TYPE="TypeLib" NAME="MyClass" FILE="c:windowssystem32MyClass.dll"-->
I try to create an object using the following line.
Set MyObj = Server.CreateObject("MyClass")
I get the error "Invalid class string " on that line.
What am I doing wrong?
Winsock - Read Server App Variables And Object Variables
I have a simple multiple client winsock server and a client that conntects to the server. I need to add the ability to my client app to read a given variable name from the server application. I was also wondering if it is possible to have the client read object variables. For example the client can read the list of a listbox on the form of the server application.
Database On Server! Error Regarding Permission!
I really need help with this... I´m using a Microsoft Access 97 database and I put it on a server... I need to access it from a client pc and what I did is simply put the path of the server and the database like this:
Data1.DatabaseName = "\crc-serverdocuments and
settingsSERVEREscritoriodataseguridad.MDB"
Data1.RecordSource = "acceso"
Am I doing something wrong!
Object Required Error Accesing Database?
Hi i have this code so far.......and when i execute it....it says Object required.....what am i doing wrong? Is it my input in the text fields wrong..or could it be the database its referring to that doesnt contain the field...thanks......
VB Code:
Private Sub cmdFieldChange_Click()Dim oconn As New ADODB.Connectionoconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:Documents and SettingsAdministratorMy DocumentsCompProj.mdb" Dim strSQL As String strSQL = "UPDATE Customers SET " & txtField & " = '" & txtChange & "' WHERE City = '" & txtCity & "'"onconn.Execute strSQLEnd Sub
I Am Getting A Compile Error Using A Database Object In VBA (with Access)
I am fairly new to MS-Access and VBA coding. I am trying to write a routine in VBA code to parse the records in a table. I found an example that uses a Database Object and it looks like this might be a good way for me to implement this; however, I am getting a Compile Error - Invalid use of Property on the assignment of my Database Object (db) to CurrentDb().
Here is the code:
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim myCount As Integer
Dim rsCount As Integer
db = CurrentDb()
strSQL = "SELECT InventoryControlNumber from InventoryItems"
rs = db.OpenRecordset(strSQL)
rs.MoveLast
myCount = rs.RecordCount
rs.MoveFirst
For rsCount = 0 To myCount - 1
Debug.Print (rsCount)
Debug.Print (rs.Fields(0))
Debug.Print (rs.Fields(1))
Debug.Print (rs.Fields(2))
Debug.Print (rs.Fields(3))
Debug.Print (rs.Fields(4))
Debug.Print (rs.Fields(5))
rs.MoveNext
Next rsCount
' Close recordset
rs.Close
db = Nothing
I appreciate any assistance that can be provided.
FYI:
Here are the current Visual Basic References that I have checked:
[X] Visual Basic For Applications
[X] Microsoft Access 9.0 Object Library
[X] OLE Automation
[X] Microsoft ActiveX Data Objects 2.1 Library
[X] Microsoft DAO 3.6 Object Library
[X] Microsoft Office 10.0 Object Library
I am using Microsoft Access 2000 (9.0.6926 SP3)
with Visual Basic 6.0
Also....
I tried changing CurrentDb() to CurrentDB
with no parenthesis - same error.
I tried specifying DAO in my variable declarations:
Dim db As DAO.Database - same error.
Thanks,
Bill
Exporting From VB Database Table To Excel - Object Error
I am trying to export an Access table to Excel from a VB project for the purpsose of a calculation, formatting and printing.
I have come accross two problems.
The first was when I used a calculted field in the SQL statement. The calculated field was placed in the first column and I needed in the end column .
My code was:
RS.Open "Select *,cost*stockqty as Stock_Value from products", CN
objXLSheet.Range("A4").CopyFromRecordset RS.
(CN is the connection string and RS the Recordset)
I then decided to do the calculations in Excel. The procedure that I use I copied from Excel. When ran it works fine the first time. But if I run it again the line
varTable = objXLSheet.Range(ActiveCell, ActiveCell.Offset(lngNbRows - 1, 10))
causes an object error - object variable not defined (run time error 91)
This is the code I currently am running. My system is Windows XP, Visual Basic Learning Edition Version 6, and Office XP.
Sub CreateXLTAble()
Dim objXL As Excel.Application
Dim objXLBook As Excel.Workbook
Dim objXLSheet As Excel.Worksheet
Dim intCount As Integer
Set objXL = CreateObject("Excel.Application")
Set objXLBook = objXL.Workbooks.Add
Set objXLSheet = objXLBook.Worksheets(1)
Dim varTable As Variant
Dim lngNbRows As Long
Dim lngCounterRow As Long
objXL.Visible = True
objXLSheet.Activate
'RS.Open "Select *,cost*stockqty as Stock_Value from products", CN
'This inserts stock value in first column - not wanted
RS.Open "Select * from products", CN
objXLSheet.Range("A4").CopyFromRecordset RS
objXLSheet.Range("A4").Activate
lngNbRows = objXLSheet.Range("A4").CurrentRegion.Rows.Count
varTable = objXLSheet.Range(ActiveCell, ActiveCell.Offset(lngNbRows - 1, 10))
For lngCounterRow = 1 To lngNbRows
varTable(lngCounterRow, 10) = varTable(lngCounterRow, 3) * varTable(lngCounterRow, 9)
Next lngCounterRow
objXLSheet.Range("A4", objXLSheet.Range("A4").Offset(lngNbRows - 1, 10)) = varTable
objXLSheet.Range("I4", objXLSheet.Range("I4").Offset(lngNbRows - 1, 2)).Style = "Comma"
varTable = Empty
RS.Close
Set objXLSheet = Nothing
objXLBook.Close False
Set objXLBook = Nothing
objXL.Quit
Set objXL = Nothing
End Sub
Sorry for the long text.
Any explanation, help would be gratefully received. (As a newbie any knowledge, web links etc. would be real helpful)
Thanking you in anticipation
Send Software Error At The Website Database Server
Hi all
Thanks 4 previous
My next problem is that I want to send the software error that is running at the client pc at our website…
I am saving the error at the client database also then how to send them at our website database
Hope u all understand
thanks
Yet Another &"database Or Object Is Read-only&"
I'm using Visual Basic 6.0 (SP5) to view an Access 2000 database on my own PC.
The database has two tables -- Albums, which has a foreign key pointing to Labels.
Table Albums: Fields primary key TitleId,
Title,
foreign key Label_Id referencing Labels.LabelId
Table Labels: Fields primary key LabelId,
Label
Using Microsoft ADO Data Control 6.0 (SP4) (OLEDB), I created a datacontrol to step through the Albums records.
Data Control datAlbums: RecordSource="SELECT [Albums].[AlbumId],
[Albums].[Title],
[Labels].[LabelId],
[Labels].[Label]
FROM Albums, Labels
WHERE ([Albums].[Label_Id]=[Labels].[LabelId])
ORDER BY [Albums].[Title];"
This SQL statement allows me to see the Label text associated with Albums.Label_Id.
I created a text box so I can view and change Albums.Title.
Text Box txtTitle: DataSource=datAlbums,
DataField=Title
Using Microsoft ADO Data Control 6.0 (SP4) (OLEDB), I created a datacontrol so the combo box displays all of the label texts.
Data Control datLabels: RecordSource="SELECT * FROM Labels;"
Using Microsoft DataListControls 6.0 (SP3) (OLEDB), I created a DataCombo so I can select the label text from a drop-down list.
Text Box comLabel: RowSource=datLabels,
ListField=Label,
DataSource=datAlbums,
DataField=Label
I access the data just fine, including through the combo box. But when I use datAlbums to move to the next record (after changing Label via the combo box), I get this error message:
"[Microsoft] [ODBC Microsoft Access Driver] Cannot update.
Database or object is read-only."
I have tried these Cursor Types: Static, Dynamic, Keyset.
I have tried these Cursor Locations: Client, Server.
I have tried these Lock Types: Optimistic, Pessimistic.
The .mdb file is not read-only.
There is no code in the project.
I tried changing the SQL statement in datAlbums to "Albums INNER JOIN Labels", but then I get "Error in FROM clause" (I don't understand this error, either).
I'm completely stumped. I don't think I'm trying to do anything unusual. Any help would be most appreciated.
Chris
Error In Server.CreateObject("Object.Class")
<html><div style='background-color:'><DIV class=RTE>Hello,</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>I have a error when :</DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>Set oObject = Server.CreateObject("Object.Class") </DIV>
<DIV class=RTE> </DIV>
<DIV class=RTE>From my page.asp.</DIV>
<DIV class=RTE>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>and show this error :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT> </DIV>
<DIV>
<TABLE cellSpacing=5 cellPadding=3 width@0>
<TBODY>
<TR>
<TD id=tableProps vAlign=top align=left><IMG id=pagerrorImg height3 src="res://C:WINNTsystem32shdoclc.dll/pagerror.g if" width%></TD>
<TD id=tableProps2 vAlign=center align=left width60>
<H1 id=errortype style="FONT: 13pt/15pt verdana; COLOR: black"><SPAN id=errorText>The page cannot be displayed</SPAN></H1></TD></TR>
<TR>
<TD id=tablePropsWidth width@0 colSpan=2><FONT style="FONT: 8pt/11pt verdana; COLOR: black">There is a problem with the page you are trying to reach and it cannot be displayed.</FONT></TD></TR>
<TR>
<TD id=tablePropsWidth width@0 colSpan=2><FONT id=LID1 style="FONT: 8pt/11pt verdana; COLOR: black">
<HR color=#c0c0c0 noShade>
<P id=LID2>Please try the following:</P>
<UL>
<LI id=instructionsText1>Open the
<SCRIPT> Homepage();</SCRIPT>
<A href="http://jalanya:8081/" target=_top><FONT color=#ff0000>jalanya:8081</FONT></A> home page, and then look for links to the information you want.
<LI id=instructionsText2>Click the <A target=_self xhref="javascript:location.reload()"><IMG height alt="refresh.gif (82 bytes)" src="res://C:WINNTsystem32shdoclc.dll/refresh.gi f" width align=middle border=0></A> <A target=_self xhref="javascript:location.reload()">Refresh</A> button, or try again later.<BR>
<LI id=instructionsText3>Click <A href="javascript:doSearch()"><IMG height alt="search.gif (114 bytes)" src="res://C:WINNTsystem32shdoclc.dll/search.gif " width align=center border=0><FONT color=#ff0000> Search</FONT></A> to look for information on the Internet.
<LI id=instructionsText4>You can also see <A onclick=Related();event.returnValue=false href=""><FONT color=#ff0000>a list of related sites.</FONT></A> </LI></UL>
<P></P>
<P><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><BR></P>
<H2 id=ietext style="FONT: 8pt/11pt verdana; COLOR: black">HTTP 500 - Internal server error <BR>Internet Explorer </H2></FONT></TD></TR></TBODY></TABLE></DIV></DIV>
<P><STRONG>Object.Class</STRONG> this register in COM+ Services.</P>
<P>Help me please.</P>
<P>Best Regards</P>
<P>Jose</P></div><br clear=all><hr>Help STOP spam with <a href="http://g.msn.com/8HMAEN/2731??PS=">the new MSN 8 </a> and get 2 months FREE*</html>
Update Record Set = Update Table In Database!!??
I have implementing a VB6 program with SQL database.
As mention in the subject, I have used rs.update to update a field in the record set. However, I found that it automatically update the field in the table where the record set created. In fact, I want the record set field update only. The table will be updated only when the user click a confirm button. How can I do that?
Error 8447 Internet Server Error When Trying To Connect To Access DSN On My Server
I'm trying to connect my vb6 application to a Access database located on my server...
I created a system DSN on my server for my Access db
I used the following code and it gives me an error ( '8447' Internet Server Error ), it is also the same error it gave me when I tried to use the code at the following post... http://www.vbcity.com/forums/topic.asp?tid=12903&highlight=access%7Cweb%7Cvb
code :
Private Sub Command1_Click()
Dim rsGeneric As ADODB.Recordset
Dim cnnGeneric As ADODB.Connection
'
Set cnnGeneric = New ADODB.Connection
'
cnnGeneric.Open "Provider=MS Remote;" _
& "Remote Provider=MSDataShape;" _
& "Remote Server=http://199.199.199.99;" _
& "Data Source=Alert;" _
& "User Id=test;Password=test;"
'
Set rsGeneric = New ADODB.Recordset
'
With rsGeneric
.CursorLocation = adUseClient
.Open "SELECT * FROM Livratemps", cnnGeneric
.ActiveConnection = Nothing
End With
End Sub
the bold line is where the error is generated...
I think it's because I don't have my RDS set up...
Well, I don't know what is RDS...
Can somebody tell me what I have to do to activate RDS and get this code working...
Thanks a lot!!
Edited by - acad on 7/11/2003 7:49:49 AM
Update ::: Syntax Error In Update Startment .... What Up ???
Dim insertSQL, updateSQL As String
Dim APP_NO As String
APP_NO = txtAppNo.Text
If UpdateOrSave = "nowupdate" Then
Set rsUpdate = New ADODB.Recordset
updateSQL = "UPDATE patents SET " & _
"[your, country, new_con, related, ftype, app_no, patent_no," & _
"fstatus, client, agent, ftitle, cref, aref, prior, mailed, filed," & _
"publish, issued, f1st, sexpires, expires, pcode, entered, modified," & _
"fby, f1, f2, p]VALUES '" & your & "','" & country & "','" & new_con & "'," & _
"'" & related & "','" & ftype & "','" & ChkString(APP_NO) & "','" & ChkString(patent_no) & "'," & _
"'" & fstatus & "','" & ChkString(client) & "','" & ChkString(agent) & "','" & ftitle & "'," & _
"'" & ChkString(cref) & "','" & ChkString(aref) & "','" & ChkString(prior) & "','" & ChkString(mailed) & "'," & _
"'" & ChkString(filed) & "','" & ChkString(publish) & "','" & ChkString(issued) & "','" & ChkString(f1st) & "'," & _
"'" & ChkString(sexpires) & "','" & ChkString(expires) & "' ,'" & pcode & "'," & _
"'" & entered & "','" & modified & "','" & fby & "','" & f1 & "'," & _
"'" & f2 & "','" & p & "' & WHERE [APP_NO] = '" & APP_NO & "';"
objAccessConnection.Execute (updateSQL)
Database Update But The Form Not Update
i meet a problem that i have 3 datacombobox, once i select different content in each of datacombo and save it.
first time(add newrecord)
datacombo1.text=3000
datacombo2.text=4000
combobox.text=5000
second time add newrecord)
datacombo1.text=3001
datacombo2.text=4001
combobox.text=5001
after save the second record, the content of first record will become the same with second record, y?
when i open Ms access and check it, it is different content which means that two record content is not same
|