473,386 Members | 1,706 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,386 software developers and data experts.

ADO.NET & SQL Server Stored Procedure

Hi,

Me again. I want to create a SQL Server StoreProcedure and I want to access
it with ADO.NET. I am using VB.NET.

Creating StoreProcedure it was easy but my question is this.

I have table with 4 Column and 6 rows. In the Column 3 for all rows I have
to insert data. The data considt of the decimal value of Croiss Exchange and
6 my variable as:

mUSD = 1.33500
mAUD = 0.91841
mSTG = 2.39300
mJPY = 0.01068
mEuro = 1.63900
mCYP = 2.85700

My Stored Procudure I have to use the CurrncyId as
USD = 1
AUD = 2
STG = 3
JPY = 4
Euro = 5
CYP = 6

Now if I create a Stored Procedure as:

"INSERT INTO tbl_DAILYRATE(xCHANGE) VALUES (@mUSD) WHERE cCHANHEID = USD"

and try to insert data into SQL Server I am getting error that says my
Stored Procedure string has error.

Does anyone know how to Create a Stored procedure to Insert data using some
column as ID Key?

Thank you in advance.

Rgds.
GC
Oct 17 '05 #1
3 2451
Niyazi,

If you use the SQL, Oracle or OleDBDataadapter in your toolbox, than a
wizard is started.

The most simple is to add as item a component. Drag one of above to your
component and the wizard starts and at the end it to create all your
command. Than you open the generated code in the component and all your code
is there.

Another way, not forever save with complex query string are the
commandbuilders

http://msdn.microsoft.com/library/de...classtopic.asp

Did you know that there is in fact a better newsgroup for this kind of
questions.

microsoft.public.dotnet.framework.adonet

I hope this helps,

Cor
Oct 17 '05 #2
Hi Cor,

Sorry I didn't realize that I was in wrong group.
I find the answere as follows:

Here is my SQL Server Stored Procedure that updates 1 column using WHERE
clause

CREATE PROCEDURE UPDATE_DAILYRATE
@mNO int,
@mCUR nvarchar (7)
AS
Update tblRATE SET mCurrency = @mCUR WHERE mCurrencyType = @mNO
GO

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++
And here is my VB.NET code that calls the above Stored Procedure and insert
the value into specific column and row
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++
Try

Dim connectionSQLSERVER As New SqlConnection(strConnSQLSERVER)
cn = connectionSQLSERVER
'INSERT USD CROSS EXCHANGE
Dim cmdUSD As New SqlCommand("UPDATE_DAILYRATE", cn)
cmdUSD.CommandType = CommandType.StoredProcedure

Dim ParamColl As SqlParameterCollection = cmdUSD.Parameters

Dim mUSDNO As Integer = 1
Dim mNO As Integer
mNO = mUSDNO
Dim paramDOVIZCINSI As SqlParameter = ParamColl.Add("@mNO", mNO)
paramDOVIZCINSI.Direction = ParameterDirection.Input

Dim mCUR As Decimal = mUSD
Dim paramDOVIZKURU As SqlParameter = ParamColl.Add("@mCUR", mCUR)
paramDOVIZKURU.Direction = ParameterDirection.Input

cn.Open()
cmdUSD.ExecuteNonQuery()

'Clear the variable
ParamColl.Clear()
mNO = 0
mCUR = 0
paramDOVIZCINSI = Nothing
paramDOVIZKURU = Nothing
cn.Close()

Catch ex As Exception
msgErrorUSD = ex.Message.ToString
End Try
I hope this helps others as well.

Again thank you very much your kind input.

Rgds,
GC
Oct 17 '05 #3
Niyazi,

You are *not* in the wrong group (you never can be in my opinon in one as
long as you don't know the other ones), however there are in my opinon
betters and therefore there is not any reason to say "Sorry" for that.

I am glad that you did succeed.

Cor
Oct 17 '05 #4

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

Similar topics

3
by: Dan Sikorsky | last post by:
How can I get the recordset attributes for a table field in SQL Server 2000 to report the field updatable attribute correctly ... mine keeps saying the fields are not updatable? That is, (...
7
by: Bercin Ates via SQLMonster.com | last post by:
I?m getting an error when I execute a stored procedure which is try to insert a row to a table. The error is: Server: Msg 1934, Level 16, State 1, Procedure SRV_SP_IS_EMRI_SATIRI_EKLE, Line 32...
2
by: Jegg | last post by:
I wrote a web app using an ASP front end (not .NET) connecting to a SQL Server 2000 (no SP) back end. Both the web server and the database server are Windows 2003 boxes. The app was running fine...
3
by: Niyazi | last post by:
Hi, Me again. I want to create a SQL Server StoreProcedure and I want to access it with ADO.NET. I am using VB.NET. Creating StoreProcedure it was easy but my question is this. I have table...
5
by: James Wong | last post by:
Hi, I am writing a vb.net2005 program that needs to create a stored procedure with SqlServerProject Template. Now, I have two questions for this stored procedure. 1) How can I import and...
1
by: den 2005 | last post by:
Hi everybody, I created several stored procedure in a local sql server 2005 express database, now when I call/execute them in the asp.net 2.0 web page, it returns an error message of "Cannot...
6
by: rn5a | last post by:
Suppose a SQL Server 2005 stored procedure looks like this: ALTER PROCEDURE SPName @UserID int SELECT COUNT(*) FROM Table1 WHERE UserID = @UserID SELECT COUNT(*) FROM Table1 In the ASPX...
4
by: scparker | last post by:
Hello, We have a stored procedure that does a basic insert of values. I am then able to retrieve the ID number created for this new record. We are currently using ASP.NET 2.0 and use N-Tier...
2
by: Neil | last post by:
I'm using Access 2000 with a SQL 7 back end. I recently implemented some code in a form's AfterUpdate event which calls a stored procedure which copies the contents of the current record to a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.