I have to build application Excel (interface) - SQL Server (backend)
I've created Data Source File "test.dsn" and tested succesfully.
SQL Server database in on the other machine.
This is a code that I am using.
And error message I am geting is "Cannot update. Database or object are read-only".
Dim cn As ADODB.Connection
Dim strSQL As String
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\pd\Desktop\Development\test.xls;" & _
"Extended Properties=Excel 8.0"
strSQL = "INSERT INTO [DSN = test.dsn].Region Values(5, 'ab');"
cn.Execute strSQL
cn.Close
Set cn = Nothing
Read-only of databse properties is not selected.If I get it right you're attempting to insert a row into excel. As long as I know it's not possible because you cannot update, insert records throught Jet provider. mojza|||Your query is unclear . Understanding you are trying to update region table In sql database .
if that's case you should then rather open an ODBC or OLE DB connection to SQL server
cn.Provider = "sqloledb"
cn.Properties("Data Source") = ServerName
cn.Properties("Initial Catalog") = DatabaseName
' If Windows NT authentication.
cn.Properties("Integrated Security")= "SSPI"
'If SQL Authentication
cn.Properties("User ID")= UserID
cn.Properties("Password") = pwd
' Open the database.
cn.Open
Dim strSQL as string
strSQL "INSERT INTO dbo.Region Values(5, 'ab')"
cn.execute strSQL
cn.close
set cn = nothing
No comments:
Post a Comment