473,409 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Help needed for new vb.net user

Hi all

Can someone please post some sample code to get me going. I have a simple table which I would like to add a new record to and have the Identity of the new row passed back to me. The table is called “ContactGroups” and it has 2 fields intID and GroupName. (Database on SQL Server 2000

I have managed to do the insert, but It is not giving me the Identity back. The code I have used is as follows, but I am sure there is a better way to do this. I have only been using VB.Net for a month and am struggling to get my head around it

Dim ReturnedID as Intege
Dim newConn as New Data.SqlClient.SqlComman

Dim cmd as New Data.SqlClient.SqlComman
Dim prmIn as New Data.sqlClient.SqlParamete
Dim prmOut as New Data.sqlClient.SqlParamete

newConn.ConnectionString = strCon

prmIn.dbType = dbType.Strin
prmIn.Direction = ParameterDirection.Inpu
prmIn.Value = “Test

prmOut.dbType = dbType.Int1
prmOut.Direction = ParameterDirection.Outpu

newConn.Open(

With cm
.CommandText = “InsGroup
.CommandType = CommandType.StoredProcedur
.Parameters.Add(prmIn
.Paramiters.Add(prmOut
.Connection = newCon

.ExecuteNonQuery(
End Wit

ReturnedID = cmd.Parameters(“prnOut”).Valu

Stored Procedure Cod

Create Procedure [dbo].[InsGroup

@Data VARCHAR(30)
@intID INT OUTPU

A

INSERT INTO ContactGroups (ContactGroup) VALUES (@Data

SET @intID = SCOPE_IDENTITY(
G

When I run the code I get an error stating that Parameter 1 is not a parameter for procedure InsGrou

Am I on the right track with this, or should I be doing this in a totally different way? Can the same be done without using Stored Procedures?

Any help would be great, especially if someone would be kind enough to post a code sample of a better way of doing this

Thank You

Mar

Jul 21 '05 #1
0 951

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike Chirico | last post by:
Hopefully this will help someone... Helpful Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Last Updated: Fri Apr 16 11:47:34 EDT 2004 The latest version of this...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
8
by: . . | last post by:
Hi I am developing a web system using ASP.NET/VB.NET with SQL Server 2005 as back end database . I need to develop a aspx page where user can see their messages after they log into the system...
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
2
by: Steve K | last post by:
I got a bit of a problem I like some help on. I'm designing an online training module for people that work in food processing plants. This is my target audience. These workers have little or no...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
7
by: isdeveloper | last post by:
Hi All, I have a problem with a table that I want to get nice data out of in a single query. The guys here reckon it can't be done in a single query but I wanted to prove them wrong !!...
8
by: 08butoryr | last post by:
Hey guys I could really use your help with some very basic java programming. I know you programming fundis out there will find this child's play but I'm struggling with it a bit because I'm...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

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.