473,461 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Invalid object name 'Product'.

HI I'M NEWBIES in visual Basic with Sql Server
i try to make a database with stored procedure and whan i run the program the give an error


"Invalid object name 'Product'."

i dont know how to fix it here is my code
Dim sqlcon As New SqlClient.SqlConnection
sqlcon.ConnectionString = "Data Source=WISEMAN\SQLEXPRESS;Initial Catalog=Product;Integrated Security=True;Pooling=False;uid=uid;pwd=pwd "
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = sqlcon
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "insertcustomer"
cmd.Parameters.AddWithValue("@Productid", TextBox1.Text)
cmd.Parameters.AddWithValue("@detail", TextBox2.Text)
sqlcon.Open()
cmd.ExecuteScalar()
cmd.ExecuteNonQuery()
sqlcon.Close()

the error at line is cmd.executescalar()
My database name is product
my name for my storedprocedure is insertcustomer
Code for insertcustomer
ALTER PROCEDURE dbo.InsertCustomer
(

@ProductID int output,
@detail varchar(50)
)


AS
SET NOCOUNT ON

INSERT INTO Productdetail
(detail)
VALUES
(@detail);

IF @@ROWCOUNT>0 AND @@ERROR>0

SELECT @Detail = detail

From Productdetail
Where (ProductID =SCOPE_IDENTITY())

if u have any idee please tell me
May 23 '07 #1
2 3091
DeMan
1,806 1GB
Hi shadwise,

Welcome to thescripts. I'm sure you will find a wealth of information ion the various forums here. I am moving this thread to the SQL server forum. You will still be able to access this particular thread through the introductions page, but future questions should be directed to the appropriate forum (which you will find by selecting "forums" on the blue bar near the top of your screen.

I hope the experts in the SQL server forum can help with your query!!
May 23 '07 #2
almaz
168 Expert 100+
...i dont know how to fix it here is my code...
if u have any idee please tell me
Does your server or database have case-sensitive collation? Please copy/paste complete error description.
I'm not sure about "Invalid object name 'Product'" problem, but there are several other problem worth mentioning:
  • Wrap SqlConnection and SqlCommand scope with using (C# keyword, don't know correct VB syntax)
  • Parameter "ProductID" should be created with Direction = ParameterDirection.Output
  • You don't need to specify "uid" and "pwd" in connection string as long as you are using integrated security.
  • Why do you execute stored procedure twice? Just call cmd.ExecuteNonQuery()
  • You don't assign inserted ProductID value to @ProductID parameter. I think your SP should look like:
    Expand|Select|Wrap|Line Numbers
    1. ALTER PROCEDURE dbo.InsertCustomer
    2. (
    3. @ProductID int output,
    4. @detail varchar(50)
    5. )
    6. AS
    7. SET NOCOUNT ON
    8.  
    9. INSERT INTO Productdetail
    10. (detail)
    11. VALUES
    12. (@detail);
    13.  
    14. IF @@ROWCOUNT>0
    15.   SET @ProductID = SCOPE_IDENTITY()
May 23 '07 #3

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

Similar topics

1
by: | last post by:
When I execute the following (with an OleDBDataAdapter), wanting to add a row to a visual foxpro table: myrow= datasetTarget.Tables(0).NewRow 'fill all columns here like.. row(i)= myvalue '...
0
by: archway | last post by:
Hi, I would like to build a hierarchy of ProductNode objects like so ProductNode ---Product Node ---ProductNode ------ProductNode ------ProductNode ---ProductNode
8
by: Glenn A. Harlan | last post by:
Why am I receiving the below error when calling - Path.GetTempFileName() The directory name is invalid. Description: An unhandled exception occurred during the execution of the current web...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
9
by: MR | last post by:
I get the following Exception "The data at the root level is invalid. Line 1, position 642" whenever I try to deserialize an incoming SOAP message. The incoming message is formed well and its...
2
by: Olivier Matrot | last post by:
Hello, I'm using a gridview with objectdatasource and custom objects collections SELECT/INSERT/UPDATE/DELETE methods are using custom objects as parameters. This is working fine. But I have a...
1
by: vidhyaprem | last post by:
i have started a small project in visual basic regarding the stock details in our textile company.It has details like product id,product name,no of items,product picture etc.. so i have created a...
1
by: samarthkumar84 | last post by:
Hi I had used following code for sending e-mail but facing this problem. I want to send this e-mail in ASP.NET using VB.NET code. I am attaching both code an output. CODE Imports...
3
by: Gustaf | last post by:
I'm working on an object model that will represent trees of products, where one product may contain others (components of a product). Each product needs to keep track of its parent and child...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.