473,498 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting PictureNames as ID

4 New Member
Hi,

I am working on a part where i use Store Procedures to Insert rows into a table (adding a new employee, to be precise).. The thing is, I am auto incrementing the ID field and there is a field where the picture name will be stored.. I am having problem trying to save the picture name same with the ID..Here is my stored procedure:

Expand|Select|Wrap|Line Numbers
  1. -- My Employees table has three fields (ID, name, picture)
  2. CREATE PROCEDURE insertEmployeeDetails(@name varchar(50), @salaryApplied DateTime, @salaryLevel int)
  3. AS
  4.     INSERT INTO Employees VALUES (@name, convert(varchar, @@IDENTITY) + '.jpg');
  5.     SET @id = @@IDENTITY
  6.     INSERT INTO Salaries VALUES (@id, @salaryApplied, @salaryLevel); 
  7.  
It seems that my picture name is always saved as NULL and I cant figure it out.. Can some one help me out here?? Thanks!
Sep 14 '06 #1
2 1079
aplus
14 New Member
Hi,

I am working on a part where i use Store Procedures to Insert rows into a table (adding a new employee, to be precise).. The thing is, I am auto incrementing the ID field and there is a field where the picture name will be stored.. I am having problem trying to save the picture name same with the ID..Here is my stored procedure:

Expand|Select|Wrap|Line Numbers
  1. -- My Employees table has three fields (ID, name, picture)
  2. CREATE PROCEDURE insertEmployeeDetails(@name varchar(50), @salaryApplied DateTime, @salaryLevel int)
  3. AS
  4.     INSERT INTO Employees VALUES (@name, convert(varchar, @@IDENTITY) + '.jpg');
  5.     SET @id = @@IDENTITY
  6.     INSERT INTO Salaries VALUES (@id, @salaryApplied, @salaryLevel); 
  7.  
It seems that my picture name is always saved as NULL and I cant figure it out.. Can some one help me out here?? Thanks!
.


Change the code as follows

CREATE PROCEDURE insertEmployeeDetails(@name varchar(50), @salaryApplied DateTime, @salaryLevel int)
AS
INSERT INTO Employees VALUES (@name);
SET @id = @@IDENTITY

UPDATE Employees set picture = CAST(@id AS VARCHAR) + '.jpg' WHERE Employees.ID = @id


INSERT INTO Salaries VALUES (@id, @salaryApplied, @salaryLevel);
[/code]

- Ankit
Sep 15 '06 #2
hykyit
4 New Member
It worked! Thanks a lot for the help!! Really appreciate it!!
Sep 15 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5846
by: Mat | last post by:
Hi, I have a system that uploads images as BLOBs in a database. I also have a function that I use to resize uploaded images before saving as files. I would like to combine these two by resising...
3
1517
by: James | last post by:
I am in the process of running my site through WC3 validation. I assume the validator at www.w3c.org cant accept cookies and so PHP is attaching &PHPSESSID=lasklijasj09jsad (or similar) to my...
14
4037
by: Miranda | last post by:
Hi, I have a ASP/vbscript program that generates random passwords. The problem is I need to insert those passwords into an Access database of 327 clients. I have the random password program...
1
2569
by: yuchang | last post by:
Hi, Using the FormView control is very efficient. But I want to do some action,like showing a success message or redirect to another page, after inserting, updating and deleting. How do I get...
2
1509
by: Krishna | last post by:
Hi, I have developed a for dataentry by using datagird in C# windows application, I am using combocolumns, textbox columns for the same, two readonly textboxcolumns for those readonly columns i...
12
4891
by: desktop | last post by:
Why does insert only work when specifying an iterator plus the object to be inserted: std::vector<intt; std::vector<int>::iterator it; it = t.begin(); t.insert(it,33); If I use push_back...
0
1752
by: gp | last post by:
I am and have been using PDO for about a year now...and have finally gotten around to solving the "DB NULL value" issues I ran into early on... I am looking for suggestions and techniques to...
6
1877
by: Bunty | last post by:
I want to insert values in the database.If i insert values one by one then it works till 4 or 5 fields then after it gives error.In my database there are more than 20 field.Pls help me.
2
3056
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
5
2141
by: rando1000 | last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record. ...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.