473,763 Members | 3,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invalid object name 'Product'.

1 New Member
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.SqlCo nnection
sqlcon.Connecti onString = "Data Source=WISEMAN\ SQLEXPRESS;Init ial Catalog=Product ;Integrated Security=True;P ooling=False;ui d=uid;pwd=pwd "
Dim cmd As New SqlClient.SqlCo mmand
cmd.Connection = sqlcon
cmd.CommandType = CommandType.Sto redProcedure
cmd.CommandText = "insertcustomer "
cmd.Parameters. AddWithValue("@ Productid", TextBox1.Text)
cmd.Parameters. AddWithValue("@ detail", TextBox2.Text)
sqlcon.Open()
cmd.ExecuteScal ar()
cmd.ExecuteNonQ uery()
sqlcon.Close()

the error at line is cmd.executescal ar()
My database name is product
my name for my storedprocedure is insertcustomer
Code for insertcustomer
ALTER PROCEDURE dbo.InsertCusto mer
(

@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 3120
DeMan
1,806 Top Contributor
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 Recognized Expert New Member
...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 = ParameterDirect ion.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.ExecuteNonQ uery()
  • 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
6328
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 ' then datasetTarget.Tables(0).Rows.Add(myrow) dataAdapterTarget.Update(datasetTarget.Tables(0)) '*
0
1410
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
17491
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 request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.IOException: The directory name is invalid.
5
3435
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 5), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide some common functionality. The Page_Load handler the failing webpage starts out like this: ...
9
6651
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 length is 642 bytes ( I have appended it to the end of this message). I suspect that the reason may have something to do with an incorrect declaration of which class to de-serialize to. In the attached code I substituted @@@@@@@ in the code below with...
2
6786
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 problem with the object that is passed back to the update method. It contains some of the properties of the original object sent during the SELECT method, but is missing others ! How can I ensure that all original object properties not modified are...
1
2654
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 table called "products".I have stored the picture of the each product as a OLE object(Bitmap Image) in product table.I tried viewing my entire "product" table in Visual basic form by using data control.I used OLE control to view the products...
1
6718
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 System.Web.HttpCookie Imports System.Web.Mail Imports System.Web.Mail.SmtpMail
3
1284
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 products. That far it seems I'll only need one class: public class Product { private string name; private Product parent; private List<Productchildren; public Product(string name) {
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9998
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9822
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7366
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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 we have to send another system
2
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.