Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Compiler Error Message: BC30456: 'AddWithValue' is

Author  Topic 

neojapanese
Starting Member

13 Posts

Posted - 2006-03-03 : 17:00:35
Compiler Error Message: BC30456: 'AddWithValue' is not a member of 'System.Data.SqlClient.SqlParameterCollection'



Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30456: 'AddWithValue' is not a member of 'System.Data.SqlClient.SqlParameterCollection'.
Line 29: cmdSelect.Parameters.AddWithValue("@username", txtUsername.Text)


this is my code is here below
_______________
<%@ Page Language="VB" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Threading" %>




<Script Runat="Server">

Sub Button_Click( s As Object, e As EventArgs )
Dim conMyData As SqlConnection
Dim cmdSelect As SqlCommand
Dim parmReturnValue As SqlParameter
Dim intResult As Integer
'Server=cedantsql1.cedant.com;uid=NYREIDB;pwd=sushiboy;database=neojapanese1_NYREIDB
If IsValid Then
conMyData = New SqlConnection("hidden")
cmdSelect = New SqlCommand("DBRegister", conMyData)
'GetParam
cmdSelect.CommandType = CommandType.StoredProcedure
parmReturnValue = cmdSelect.Parameters.Add( "RETURN_VALUE", SqlDbType.Int )
parmReturnValue.Direction = ParameterDirection.ReturnValue
'cmdSelect = New SqlCommand( "GetParam" , conMMTMP)


'cmd.Parameters.AddWithValue("@CategoryName", category)
cmdSelect.Parameters.AddWithValue("@username", txtUsername.Text)
'cmdSelect.Parameters.AddWithValue("@username", txtUsername.Text)
cmdSelect.Parameters.AddWithValue("@password", txtPassword.Text)
conMyData.Open()
cmdSelect.ExecuteNonQuery()
intResult = cmdSelect.Parameters( "RETURN_VALUE" ).Value
conMyData.Close()
If intResult = - 1 Then
lblMessage.Text = "Username Already Registered!"
Else
FormsAuthentication.RedirectFromLoginPage( txtUsername.Text, False )
End If
End If

End Sub

</Script>

<html>
<head><title>Register.aspx</title></head>
<body>
<form Runat="Server">

<h2>Please Register</h2>
<p><b>Login information:</b> </p>

<asp:Label
ID="lblMessage"
ForeColor="Red"
Font-Bold="True"
EnableViewState="False"
Runat="Server" />
<p>
<b>Username:</b>
<br>
<asp:TextBox
ID="txtUsername"
Runat="Server" />
<asp:RequiredFieldValidator
Text="Required!"
Runat="Server" />
<p>
<b>Password:</b>
<br>
<asp:TextBox
ID="txtPassword"
Runat="Server" />
<asp:RequiredFieldValidator
Text="Required!"
Runat="Server" />
<p>
<p>
<b>Personal information:</b>

</form>
<p><b>First Name:</b>
<br>
<asp:TextBox
ID="txtFN"
Runat="Server" />
<asp:RequiredFieldValidator

Text="Required!"
Runat="Server" />
</p>
<p><b>Last Name:</b>
<br>
<asp:TextBox
ID="txtLN"
Runat="Server" />
<asp:RequiredFieldValidator

Text="Required!"
Runat="Server" />
</p>
<p><b>Email:</b>
<br>
<asp:TextBox
ID="txtUsername2"
Runat="Server" />
<asp:RequiredFieldValidator
Text="Required!"
Runat="Server" />
</p>
<p> </p>
<p>
<asp:Button
Text="Register!"
OnClick="Button_Click"
Runat="Server" />

</p>
<p> </p>
</body>
</html>

aaronlj
Starting Member

1 Post

Posted - 2006-03-22 : 14:57:49
I am getting a similar error and I have not been able to fix it. Did you find a fix?
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2006-03-22 : 15:41:13
Maybe a different provider supports that, but I've never seen that notation with .Net 1.0 or 1.1.

I've always done this:

cmdSelect.Parameters.Add("@Username", SqlDbType.VarChar, 50).Value = txtUsername.Text


Michael

<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>

Opinions expressed in this post are not necessarily those of TeleVox Software, inc. All information is provided "AS IS" with no warranties and confers no rights.
Go to Top of Page

bhar
Starting Member

9 Posts

Posted - 2006-03-24 : 05:42:51
Hi,

Alternatively, you can do like this.

prmcat = New SqlParameter()
prmcat.ParameterName="@mcode"
prmcat.Direction=ParameterDirection.Input
prmcat.SqlDbType=SqlDbType.Char
prmcat.Size=6
prmcat.Value=mcode.text
comSelect.Parameters.Add(prmcat)




Go to Top of Page
   

- Advertisement -