|
Hmm...Despite some sintax errors I could notice in the procedure (maybe from when you paste in here), I think you're problem could be the way the procedure is executing the insert.
When you do:
INSERT INTO Customer (Field1,Field2) VALUES (Value1,Value2);
You are addressing the values (Value1,Value2) in the corresponding order as the appear in the field list (Field1,Field2), but as you did:
INSERT INTO Customer VALUES (Value1,Value2);
You are putting the values in the order the fields appear in the table, so if the table has one more column or a column in the wrong order, you could get unwanted results.
Try using the first form of insert. If it did not work, post the table structure to see if we can help you.
Regards
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
Thanks Cio!
The INSERT syntax I have used is correct in SQL 2008. The syntax you have suggested to me for use is causing an error when I try to save it as a stored procedure. I am experiencing the same problem for all the other stored procedures in SQL SERVER. I am newbie to SQL and I have no idea what is causing the problem. When I use query, it is working fine but when I try to invoke a storedprocedure, it is causing an error.
The table structure is as show below.
COLUMN NAME DATA TYPE ALLOW NULLS
(PK)CustomerNumber bigint False (IDENTITY COLUMN)
(FK)UserType bigint False
AccountStatus bit False
FirstName nvarchar(50) False
MiddleInitial nchar(2) True
LastName nvarchar(50) False
EmailAddress nvarchar(125) False
What a curious mind needs to discover knowledge is noting else than a pin-hole.
modified on Sunday, September 21, 2008 5:40 AM
|
|
|
|
|
Hi,
Basic cause for this is that for some reason you are trying to insert NULL to GetUserType. Reasons in your case could be:
- parameter SetUserType has a value of NULL when call to sp is made (but I understood you have checked this)
- when using INSERT syntax where you don't define columns for the values, you can get mixed in column order as Caio pointed out. Modifying the insert statement to following may help. Also notice GetTitle parameter. Didn't find any corresponding field in your table based on your description
INSERT INTO Customer
(
UserType,
AccountStatus,
FirstName,
MiddleInitial,
LastName,
EmailAddress )
VALUES (
@GetUserType,
@GetAccountStatus,
@GetTitle, <-------- Where is this parameter going
@GetFirstName,
@GetMiddleInitial,
@GetLastName,
@GetEmailAddress)
- also I noticed the call to StoredProcedure3 inside the values portion. Is this intended
@GetEmailAddress,
EXEC StoredProcedure3 <------
RETURN
Mika
The need to optimize rises from a bad design
|
|
|
|
|
Thanks a lot!
The problem has been solved. The EXEC statement was causing the problem. I removed it and then it worked.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
You're welcome
Mika
The need to optimize rises from a bad design
|
|
|
|
|
like it shows the table has a column that can not be null!!!
go to sql server and set column to allow nulls, then if you have to enter a null value code like this in c#:
...
sql_cmd.Parameters.Add("@GetUserType", SqlDbType.BigInt).Value = DBNull.Value;
...
ok? the parameter will be set for null
my coding is diferent, don´t know if your doing it right but check this in your code also:
JUNEYT wrote: SetUserType.IsNullable = False
That is c# code you are in the wrong forum!!! others will not anser to your post ok?
Good luck!!!
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Dear ALL,
I am not getting SQL Server Databse files in the installer
It gives only 2 options of SQL Server Native Client & SQL server Setup support files,
i have checked the files & it was installed over my home PC Easily but its not getting successful over my office PC, i have 4, 5 different DVD's of it & tried over 3,4 different PC but not getting the trouble identified , also i have checked added program list in control panel , no SQL instance was found before, kindly help me in this regard.
|
|
|
|
|
Hi , hw can i give permission so that no one can change my code in stored procedure , and only particular member insert , update , delete my stored procedure which i make in my own database.
Thanx in Advance
|
|
|
|
|
You create specific database users, then let the clients connect to the db with the appropriate username & password
|
|
|
|
|
Harvey Saayman wrote: clients connect to the db with the appropriate username & password
Or use a trusted connection - Must better than exposing passwords in connection strings.
|
|
|
|
|
allow users only to trigger your store procedures, if you only build reports procedures they cannot change data.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hi,
A very newbie question to all you learned folks. I am writing a trigger through Enterprise Manager (using the option New Stored Procedure...)
The following is my code
create trigger trig1 on table1
for insert
as
select * from table2
go
When I check the syntax by pressing the Check Syntax button it says Syntax Ok but when I press the OK button to close the stored procedure editor
it states the following error
Error 21001:[SQL-DMO]Stored Procedure definition must include name and text (for StandardStoredProcedure or library name for ExtendedStoredProcedure)
Now the stupid question, how do I write a trigger through SQL Enterprise Manager for a particular table.
|
|
|
|
|
What are you really trying to create? A trigger or a Stored Procedure?
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
If you're creating a trigger, don't use New Stored Procedure in the management studio, instead:
- navigate to the table you want to create the trigger on
- expand the tree
- select Triggers
- and then New Trigger option.
Mika
The need to optimize rises from a bad design
|
|
|
|
|
I have tried MSSQL 2000 server error handling part but I still have Error Message in SQL Analyzer. I called the procedure from the application and it failes because of Error Message. Is it possible to eliminate error message ?
|
|
|
|
|
Yes, fix the cause of the error!
You haven't given anyone much information to help, have you?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
hi all, this is a problem in SqlExpress when i insert a row by using ado.net in windows application .ado.net tell me that this row is inserted successfully but in sqlexpress table is not inserted why?
essampro
|
|
|
|
|
you could:
- make sure you commit the work if in a transaction
- try to isolate the error by trying to copying the command in the application right before you send to the database (in debug mode) and trying to execute directly on the database.
- make sure you're not using some kind of try-catch that could illude you of being sucessfully in the application
but anyway, how did ado.net told you the row was inserted?
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
hi caiokf,thanks for your attention.i would like to you that when i insert a row in sqlexpress by hand(without using ado.net) , a row is insert successfully .but when i use ado.net row is not inserted without giving any errors.i invite you to try this by yourself
EssamPro
|
|
|
|
|
can you post your code + the error you're getting?
and...are you using a stored procedure? or insert statement directly?
if it was the case, put your stored procedure
Regards
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
Check the Connection String, is UserInstance set to True ?
This may be the problem.
Google for an explanation.
I don't speak Idiot - please talk slowly and clearly
|
|
|
|
|
Hi all ,i want that sqlserver 2005 send to my applicationin c#.net notification or message after insertion a row
thanks
essampro
|
|
|
|
|
Can you be more specific on your question?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
my database is having huge data and log files.
i want to know is if i shrink both data and log file then is there any data loss or harm to database?
can i shrink the master, tempdb database..??
Thank you
jayesh
|
|
|
|
|
Jes Talsaniya wrote: shrink both data and log file then is there any data loss or harm to database?
No and No
Jes Talsaniya wrote: can i shrink the master, tempdb database..??
Don't think so, and yes
Bob
Ashfield Consultants Ltd
|
|
|
|