Hi,
I am inserting values into databse using sqlserver stored
procedures. i wrote stored preocedure,but in codebehind file(.vb
file)
i dont know how to pass the parameters, i got error message like this
"System.Data.Sq lClient.SqlExce ption: Procedure or Function
'sp_insert'
expects parameter '@TestId', which was not supplied. at
System.Data.Sql Client.SqlConne ction"
I wrote Stored Procedure Like this:
ALTER PROCEDURE [dbo].[sp_insert]
(@TestId int output ,
@Name varchar(50),
@Number varchar(50),
@Date Datetime
)
AS
INSERT INTO Testtable(Name, Number,Date)
VALUES
(@Name, @Number,@Date)
SELECT @TestId=@@IDENT ITY.
This is My .vb code:
sqlcon = New
SqlConnection(S ystem.Configura tion.Configurat ionManager.AppS ettings("Connec *
tionstring"))
Try
sqlcon.Open()
sqlcmd = New SqlCommand("sp_ insert", sqlcon)
sqlcmd.CommandT ext = "sp_insert"
sqlcmd.Connecti on = sqlcon
sqlcmd.CommandT ype = CommandType.Sto redProcedure
sqlcmd.Paramete rs.Add("@Name", SqlDbType.VarCh ar).Value =
txtname.Text
sqlcmd.Paramete rs.Add("@Number ", SqlDbType.VarCh ar).Value
= txtnumber.Text
sqlcmd.Paramete rs.Add("@Date", SqlDbType.DateT ime).Value
=
txtdate.Text
param = sqlcmd.Paramete rs.Add("@RetunV alue",
SqlDbType.VarCh ar, 50)
param.Direction = ParameterDirect ion.Output
sqlcmd.ExecuteN onQuery()
lblstatus.Text = "successfullyin serted"
sqlcon.Close()
ReturnValue = param.Value
Catch ex As Exception
lblstatus.Text = ex.ToString
End Try.
Please check this code and find out my Error.
i dont know how to pass that output parameter, please write that
code .
Regards,
Sirisha.
Regards,
Sirisha. 0 1855 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris |
last post by:
Any help would be appreciated.
I am running a script that does the following in succession.
1-Drop existing database and create new database
2-Defines tables, stored procedures and functions in the database
3-Imports data using bulk insert
4-Analyzes data using stored procedures
I would like to improve the performance of the analysis...
|
by: Mike |
last post by:
Hello,
I'm currently working on debugging a very large DTS package that was
created by someone else for the purpose of importing data into my
company's database. The data is mainly user/contact-related data for
our customer base.
We ran into problems when one import, of about 40,000 rows, took
upwards of six hours to complete. Many of...
|
by: Eli |
last post by:
Hi all
We currently have a strange problem with calling a Stored Procedure
(SQL Database) in our C# Project. The only error I get is "System
error" which says a lot :)
Background:
We have several stored procedures to Insert and update datas in our
SQL database. Some stored procedures are smaller (insert datas in only
one table) and some...
|
by: Lelle |
last post by:
Hello !
how can i insert text containg code examples from a textbox into a database
using SQL insert statment.
i have no problem to just add text that dont contains code and script
examples or the illegal chars for the insert command
is it possible to encasulate the text/string so the server doesnt reads the
string as a command?
|
by: Crash |
last post by:
C#
VS 2003
..Net Framework V1.1 SP1
SQL Server 2000 SP3
Enterprise Library June 2005
I'm working with some code {not of my creation} that performs the
following sequence of actions:
- Open SqlConnection using SQL authentication with UID & PWD in connect
| |
by: .Net Sports |
last post by:
I'm trying to insert records into an sql database coming from a page
using the request
..form method. The table "general" has a primary key 'geid .' I get the
following error:
Cannot insert the value NULL into column 'geid', table 'general';
column does not allow nulls. INSERT fails.
....not sure how to include the 'geid' field into the...
|
by: Matt |
last post by:
So as you all know the great thing about ADO.NET is that I can take an
entire table from a database and dump it into an in memory datatable
using ADO.NET.
Well my question is that now that I have this temporary table, is it
possible to run SQL commands against it like it were an "actual"
table.
To give a simplistic example, lets say I...
|
by: morebeer |
last post by:
I got the same problem, hundreds of SQL tables been infected with this
malicious javascript code. But although closing the original injection
leak and also having replaced all strings in all tables, my tables
being infected again and again. I already checked all stored
procedures but couldn't find anything suspicious. Any help how to get
rid...
|
by: paulmitchell507 |
last post by:
I think I am attempting a simple procedure but I just can't figure out
the correct syntax. My asp (classic) page runs a SELECT query to
obtain dates and ID's from 2 tables
uSQL = "SELECT cal_date, holiday_ID from Calendar, holiday_tbl WHERE
(((calendar.cal_Date) Between . And
.)) And Email_sent=0 AND Staff_ID=" & Staff_ID
This works...
|
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...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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...
|
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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...
|
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
| |
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...
| |