Showing posts with label access. Show all posts
Showing posts with label access. Show all posts

Friday, March 30, 2012

Inserted/deleted table.

Hi,

I am currently working on a MS SQL server 2000.

I would like to access the data inserted or deleted within a trigger. however the built-in tables -- inserted and deleted -- are not accessible. anyone knows why? And is there any other way to do this?

Thankspost your t-sql code that you used to access the inserted/deleted tablessql

Wednesday, March 28, 2012

Insert, Update queries

Is there any way to use a graphical designer to build your insert & update SQL statements in Enterprise manager? I mean Access has an EASY way to build them, surely SQL does too?

I would just build them in Access and copy the SQL, but then I'm stuck replacing all the "dbo_" with "dbo." and other little nuances.No graphical way. Lots of people use Access exactly like you mentioned. Another way is with Query Analyzer. Right click the table in the object browser and you'll have options for scripting INSERTS, UPDATES, DELETES, etc. Not graphical, but handy to eliminate some typing and spelling mistakes.|||Thanks for the reply!

You know, in many ways Access is superior to SQL Server. Easy interface for designing and building any types of queries and forms, easy to link tables to any form of database (Oracle, SQL Server, DBF), Great reporting tool, cheap, and so on and so forth...

if only it was more stable and faster for use in a larger corporate setting with many users hitting it constantly, it would be my #1 choice for database development.|||Access gets some bad press, but it's good at what it's meant to be. Doesn't hold a candle to SQL Server for what it's not meant to be. Just a case of the right tool for the job.

Monday, March 19, 2012

Insert syntax error

I'm not quite sure if this is the right forum. I am trying to execute a insert statement. Using an ADO connection with Jet 4 (MS Access and VBA).

"INSERT INTO tblLocking (Table, Record, User) VALUES ('tblDiscrepancy','70','mnewheiser')"

I am getting a syntax error on the above statement. All fields that i am inserting to (Table, Record and User) are all text types, and the table does exist.

There is a fourth column in the table (LockID) which is a Access [Auto-Number] type(why i'm not sure on the forum) do i need to declare this in the statement.

Any help would be much appreciated as its is beginning to drive me mad.

CheersOk, so it appears the solutions wasn't as complicated as i thought it would be.

Although 'Table' and 'User' where valid columns in the table, they are also reserved words (or something like that). So in the statement they needs [ and ] around them (i.e. [Table])

Don't have to slit my wrists now. :)

Friday, February 24, 2012

Insert produces error

Hi,

Using SQL Server 2000 with Windows 2000 Adv Server
&
Microsoft Access linked table (running stored procedure using ADO as
follows:

************************************************** ********
Private Sub cboAddrType_NotInList(NewData As String, Response As Integer)

Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Dim msg As String

On Error GoTo Err_AddrType_NotInList
'Exit the procedure if the combo box was cleared
If Trim(NewData) = "" Then Exit Sub

'Confirm that the user wants to add AddrType
msg = "'" & Trim(NewData) & "' is not in the list." & vbCr & vbCr
msg = msg & "Do you want to add it?"
If MsgBox(msg, vbQuestion + vbYesNo) = vbNo Then
'If the user chose not to add AddrType, set the response
'argument to supress an error message and undo changes.
Response = acDataErrContinue
MsgBox "No record added.", vbOKOnly, "Action Cancelled"
Else
'If the user chose to add AddrType, open a recordset
'using the AddrType table

Set cmd = New ADODB.Command
Set cnn = New ADODB.Connection
cnn.Open "Provider=SQLOLEDB;Data Source=penland01;Initial
Catalog=groomery;Integrated Security=SSPI;"

cmd.ActiveConnection = cnn
cmd.CommandText = "spInsertAddrType"
cmd.CommandType = adCmdStoredProc

Set prm = cmd.CreateParameter("AddrType", adVarChar,
adParamInput, , Trim(NewData))
cmd.Execute Parameters:=prm
'Set Response argument to indicate that new data is being added
Response = acDataErrAdded

cnn.Close
Set cnn = Nothing
End If

Exit_AddrType_NotInList:
Exit Sub

Err_AddrType_NotInList:
MsgBox Err.Description
Response = acDataErrContinue
************************************************** ********

"NewData" is a text string - in this case "Test"

The stored procedure referenced in the code is:

************************************
CREATE PROCEDURE [spInsertAddrType]
(@.AddrType [nvarchar](50))

AS
INSERT INTO [groomery].[dbo].[tblAddrTypes]
([fldAddrType])

VALUES
(@.AddrType)
GO
*************************************

When I execute this code, I receive the following error

"Cannot update identity column 'fldAddrTypeID'."

fldAddrTypeID is configured as follows:

***************************
Data Type = int
Identity = Yes
Identity Seed = 1
Identity Increment = 1
***************************

The documentation I've found online concerning this error says that it is
produced when you try to supply a value for an identity field without SET
IDENTITY_INSERT on. Obviously I am NOT specifying a value, so I can't
figure why I'm getting this error.

Thanks for any help you can offer.

ToddHi,

Found the answer elsewhere but thought I'd share it here in case someone
else has this problem.

Access's upsizing wizard created a trigger on tblAddrTypes which (evidently)
was meant to emulate Access's autonumber functionality. Once I deleted that
trigger, everything worked fine.

Todd
"Todd" <infoNOSPAM@.MAPSONgroomery.biz> wrote in message
news:T1j5e.11405$FN4.303@.newssvr21.news.prodigy.co m...
> Hi,
> Using SQL Server 2000 with Windows 2000 Adv Server
> &
> Microsoft Access linked table (running stored procedure using ADO as
> follows:
> ************************************************** ********
> Private Sub cboAddrType_NotInList(NewData As String, Response As Integer)
> Dim cnn As ADODB.Connection
> Dim cmd As ADODB.Command
> Dim prm As ADODB.Parameter
> Dim msg As String
> On Error GoTo Err_AddrType_NotInList
> 'Exit the procedure if the combo box was cleared
> If Trim(NewData) = "" Then Exit Sub
> 'Confirm that the user wants to add AddrType
> msg = "'" & Trim(NewData) & "' is not in the list." & vbCr & vbCr
> msg = msg & "Do you want to add it?"
> If MsgBox(msg, vbQuestion + vbYesNo) = vbNo Then
> 'If the user chose not to add AddrType, set the response
> 'argument to supress an error message and undo changes.
> Response = acDataErrContinue
> MsgBox "No record added.", vbOKOnly, "Action Cancelled"
> Else
> 'If the user chose to add AddrType, open a recordset
> 'using the AddrType table
>
> Set cmd = New ADODB.Command
> Set cnn = New ADODB.Connection
> cnn.Open "Provider=SQLOLEDB;Data Source=penland01;Initial
> Catalog=groomery;Integrated Security=SSPI;"
> cmd.ActiveConnection = cnn
> cmd.CommandText = "spInsertAddrType"
> cmd.CommandType = adCmdStoredProc
> Set prm = cmd.CreateParameter("AddrType", adVarChar,
> adParamInput, , Trim(NewData))
> cmd.Execute Parameters:=prm
> 'Set Response argument to indicate that new data is being added
> Response = acDataErrAdded
> cnn.Close
> Set cnn = Nothing
> End If
> Exit_AddrType_NotInList:
> Exit Sub
> Err_AddrType_NotInList:
> MsgBox Err.Description
> Response = acDataErrContinue
> ************************************************** ********
> "NewData" is a text string - in this case "Test"
> The stored procedure referenced in the code is:
> ************************************
> CREATE PROCEDURE [spInsertAddrType]
> (@.AddrType [nvarchar](50))
> AS
> INSERT INTO [groomery].[dbo].[tblAddrTypes]
> ([fldAddrType])
> VALUES
> (@.AddrType)
> GO
> *************************************
> When I execute this code, I receive the following error
> "Cannot update identity column 'fldAddrTypeID'."
> fldAddrTypeID is configured as follows:
> ***************************
> Data Type = int
> Identity = Yes
> Identity Seed = 1
> Identity Increment = 1
> ***************************
> The documentation I've found online concerning this error says that it is
> produced when you try to supply a value for an identity field without SET
> IDENTITY_INSERT on. Obviously I am NOT specifying a value, so I can't
> figure why I'm getting this error.
> Thanks for any help you can offer.
> Todd

INSERT Problem

I'm having an issue inserting records into an SQL server. We're using Access 2003 as the front end with an SBS2003 box running sql with all the latest patches.

Everything works fine with one computer accessing but when we have multiple computers (5) we experience problems. Each order has multiple details rows that are being inserted into a table using ADO w/SQL commands. The rows for each order are entered into the table and the appear correct. Then the rows for the specific order appear to get removed and then all added again (with the same time stamp) but with some of the data missing.

Any help would be appreaciated.

Cheers,
Jon_got code? see Brett's sticky at the top of the page. It sounds like you have an application bug dealing with concurrency.|||got code? see Brett's sticky at the top of the page. It sounds like you have an application bug dealing with concurrency.

Exactly the problem! We found a bug in the code and it was a concurrency issue.

Thanks for your help!

Cheers,
Jon_|||I am awesome at blind chess but not chess with the blindman|||Well, I read the title and I was thinking that some sort of initimate relationship manual might come in handy

Insert picture

Access allows to insert manually an image into OLE Object type field very
easy. I was wondering if there is a simple way to insert an image into image
type field in SQL Server using Enterprise Manager (not programmatically)
Thank you
Al
Hi
No, EM does not support it. You need to use an application to do it.
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"vul" <aaa@.optonline.net> wrote in message
news:%23skF6VWDGHA.3920@.tk2msftngp13.phx.gbl...
> Access allows to insert manually an image into OLE Object type field very
> easy. I was wondering if there is a simple way to insert an image into
> image
> type field in SQL Server using Enterprise Manager (not programmatically)
> Thank you
> Al
>