Hi to all ,
I am developing website in asp.net2.0 using VB.
I wrote sored procedure,

ALTER PROCEDURE SELECTSC
	
	(
	@cid INT
	)
	
AS
BEGIN
SELECT sc FROM collage_detail WHERE c_id=@cid
END
	/* SET NOCOUNT ON */ 
	RETURN

and in vb I wrote on button click,

cmd.CommandType = CommandType.StoredProcedure
                    cmd.CommandText = "SELECTSC"
'ot contains integer value
Dim ot As Integer = op(i)
                cmd.Parameters.Add("@cid", SqlDbType.Int).Value = ot

while running application it gives me error that Function or procedure SELECTSC too many arguments specified.

In collage_detail table I want value in sc column as per the c_id(collage id) . I will provide collage Id from array in while loop.
because I want to check for 5 different collages.

please give me any solution...!

Recommended Answers

All 3 Replies

I can't see what you're doing wrong. I did the same thing and it works as expected:

IF OBJECT_ID('sp_Test', 'P') IS NOT NULL DROP PROCEDURE sp_Test
GO
CREATE PROCEDURE sp_Test
(
  @id int
)
AS
BEGIN
  Select * From sysobjects
END
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		Dim conn As New SqlClient.SqlConnection("Data Source=apex2006sql;Initial Catalog=Leather;Integrated Security=True;")
		conn.Open()
		Dim cmd As New SqlClient.SqlCommand("sp_test", conn)
		cmd.CommandType = CommandType.StoredProcedure
		cmd.Parameters.Add(New SqlClient.SqlParameter("@id", System.Data.SqlDbType.Int)).Value = 1
		Dim dr As SqlClient.SqlDataReader = cmd.ExecuteReader()
		Dim dt As New DataTable()
		dt.Load(dr)
		dr.Close()
		cmd.Dispose()
		conn.Dispose()

		MessageBox.Show(dt.Rows.Count.ToString())
	End Sub

See if that works and then compare it against your code.

Hi sakhi kul,

Post full VB.NET code. It will help to identify the issue.

Are you putting the above VB.NET code segment in a For loop?

Where do you fill your data set. after for loop?

Hi , I am developing a Centralized Admission System in which Students fill their entrance form & collages will provide theirs information about all reservations seats etc.
After entrance result will declared & allotments based on these merit list & merit number. Student fill option form in which he/she gives 5 options of collages where he/she want to take admission.

The error comes in this allotment process...

I have following tables
1.collage_detail( I mainly deal with sc,open,vj.. seats)
2.student_deatail( In this process cast is imp. , s_id is primary key)
3. option list(opt1,opt2,opt3,op4,op5 : collage id student opt for..)
4.result(mainly mertinumber is imp)


So firstly i retrieve all information regarding allotment like student cast, & I want to check weather this cast seats are available in particular collages for which student opt,
I write code in while loop which run 5 times( If student get allotted in first option then loop will break)

when I run above code 2 time the error occurred at datareader
I am using same command object & connection object.Is this the reason of error..?

cmd.commandtext="SELECT * FROM collage_detail WHERE c_id=@opt1"

 While i < 5
                    Dim ot As Integer = op(i)
                    cmd.Parameters.AddWithValue("@opt1", op(i))

                    ' cmd.Parameters.Add("@cid", SqlDbType.Int).Value = ot

                    'cmd.Parameters.AddWithValue("@sid", sid)
                    Dim readcounter As SqlDataReader = cmd.ExecuteReader()
                    readcounter.Read()

                    Dim avseat As Integer = readcounter(0)
                    If avseat > 0 Then
                        Dim adcon As String = "INSERT INTO allotement(s_id,c_id) VALUES(@sid1,@c_id)"
                        cmd.CommandText = adcon
                        Dim con3 As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CAP.mdf;Integrated Security=True;User Instance=True")
                        con3.Open()
                        cmd.Parameters.AddWithValue("@c_id", op(i))
                        Dim s As Integer = r("s_id")
                        cmd.Parameters.AddWithValue("@sid1", s)

                        cmd.Connection = con3
                        cmd.ExecuteNonQuery()

                        chk = 1
                    Else

                        i = i + 1
                    End If
                    '  opt1 = r("opt2")

                    If chk = 1 Then
                        i = 5
                    End If
                End While

I run above code many times ( and in this code i didn't use stored procedure) but it gives me error that "Bad Request"
Please Reply!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.