SqlParameter[]

A

alex

I copied the following code from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp

SqlParameter[] paramsToStore = new SqlParameter[2];
paramsToStore[0] = New SqlParameter("@cat", SqlDbType.Int);
paramsToStore[1] = New SqlParameter("@Sup", SqlDbType.Int);

I've put it in my Global.asax.cs file to call a stored procedure from there.

I've added the necessary namespaces:

using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

on the following 2 lines from above:

paramsToStore[0] = New SqlParameter("@cat", SqlDbType.Int);
paramsToStore[1] = New SqlParameter("@Sup", SqlDbType.Int);

my vs.net is giving me a red wavy line under SqlParameter saying ";
expected"

I copied the code from msdn and it seems to be the same elsewhere on the
web, I don't see what the problem is.
 
J

Jon Skeet [C# MVP]

alex said:
I copied the following code from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbd
a/html/daab-rm.asp

SqlParameter[] paramsToStore = new SqlParameter[2];
paramsToStore[0] = New SqlParameter("@Cat", SqlDbType.Int);
paramsToStore[1] = New SqlParameter("@Sup", SqlDbType.Int);

I've put it in my Global.asax.cs file to call a stored procedure from
there.

I've added the necessary namespaces:

using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

on the following 2 lines from above:

paramsToStore[0] = New SqlParameter("@Cat", SqlDbType.Int);
paramsToStore[1] = New SqlParameter("@Sup", SqlDbType.Int);

my vs.net is giving me a red wavy line under SqlParameter saying ";
expected"

I copied the code from msdn and it seems to be the same elsewhere on the
web, I don't see what the problem is.

C# is case-sensitive - you need "new", not "New". The example lines you
copied were from Visual Basic.
 
F

Frans Bouma [C# MVP]

I copied the following code from
http://msdn.microsoft.com/library/default.asp?url=/library/en- us/dnbda/ht
ml/daab-rm.asp

SqlParameter[] paramsToStore = new SqlParameter[2];
paramsToStore[0] = New SqlParameter("@Cat", SqlDbType.Int);
paramsToStore[1] = New SqlParameter("@Sup", SqlDbType.Int);

I've put it in my Global.asax.cs file to call a stored procedure from
there.

I've added the necessary namespaces:

using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

on the following 2 lines from above:

paramsToStore[0] = New SqlParameter("@Cat", SqlDbType.Int);
paramsToStore[1] = New SqlParameter("@Sup", SqlDbType.Int);

my vs.net is giving me a red wavy line under SqlParameter saying ";
expected"

I copied the code from msdn and it seems to be the same elsewhere on the
web, I don't see what the problem is.

use 'new' instead of 'New'

Frans
 
A

alex

Thanks guys! I can't believe I was stumped by that. That code is in the c#
code section on that msdn page, it's a typo.

Frans Bouma said:
I copied the following code from
http://msdn.microsoft.com/library/default.asp?url=/library/en- us/dnbda/ht
ml/daab-rm.asp

SqlParameter[] paramsToStore = new SqlParameter[2];
paramsToStore[0] = New SqlParameter("@Cat", SqlDbType.Int);
paramsToStore[1] = New SqlParameter("@Sup", SqlDbType.Int);

I've put it in my Global.asax.cs file to call a stored procedure from
there.

I've added the necessary namespaces:

using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

on the following 2 lines from above:

paramsToStore[0] = New SqlParameter("@Cat", SqlDbType.Int);
paramsToStore[1] = New SqlParameter("@Sup", SqlDbType.Int);

my vs.net is giving me a red wavy line under SqlParameter saying ";
expected"

I copied the code from msdn and it seems to be the same elsewhere on the
web, I don't see what the problem is.

use 'new' instead of 'New'

Frans
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top