Showing posts with label sqlclient. Show all posts
Showing posts with label sqlclient. Show all posts

Wednesday, March 7, 2012

Error2Text is not a member of System.Data.SqlClient.SqlParameter

Error 2 'Text' is not a member of 'System.Data.SqlClient.SqlParameter'.

I think this error has something to do with the lack of an Import command, anyone point me in the right direction?

sorry, I've decided to upload all the code of default.aspx.vb...I'm trying to make a mailing list sign up. So member can add their name and email for a monthly newsletter. I'm getting three errors, the one posted above on each of the three text boxes. what do I do?

Thanks very much

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddButton.Click

Dim connect As String
connect = "data source='.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True'"
Dim sqlconnect As New System.Data.SqlClient.SqlConnection(connect)
Dim command As String

command = "insert into DataForm values(@.firstname,@.lastname,@.email)"
Dim sqlcommand As New System.Data.SqlClient.SqlCommand

sqlcommand.CommandText = command
sqlcommand.Connection = sqlconnect

Dim firstname As New System.Data.SqlClient.SqlParameter()

firstname.ParameterName = "@.firstname"
firstname.Value = firstname.Text
firstname.SqlDbType = System.Data.SqlDbType.VarChar
sqlcommand.Parameters.Add(firstname)

Dim lastname As New System.Data.SqlClient.SqlParameter()

lastname.ParameterName = "@.lastname"
lastname.Value = lastname.Text
lastname.SqlDbType = System.Data.SqlDbType.VarChar
sqlcommand.Parameters.Add(lastname)

Dim email As New System.Data.SqlClient.SqlParameter()

email.ParameterName = "@.email"
email.Value = email.Text
email.SqlDbType = System.Data.SqlDbType.VarChar
sqlcommand.Parameters.Add(email)

sqlconnect.Open()
sqlcommand.ExecuteNonQuery()
sqlconnect.Close()

End Sub

Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Protected Sub AddButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddButton.Click

End Sub
End Class

|||

Hi,

I think you need to start naming your objects a bit better, seems to me that both your textbox and your SqlParameter have the same name(e.g. firstname, lastname)

I'm pretty sure that's the source of your problems. Try renaming either the textbox control or the SqlParameter (or both) to like txtFirstname and parFirstname.

Good Luck,

Tim Lensen

|||

thanks for the reply I'll give it a go and get back shortly!

Thanks!

-Ian

|||thanks that solved my problem!

Sunday, February 26, 2012

Error:Cannot resolve collation conflict for equal to operation.

Exception information:System.Data.SqlClient.SqlException: Cannot resolve collation conflict for equal to operation.
Who can tell me how to resolve this problem?
ThxIs this an error you've seen here on the ASP.NET Forums? (After all, you've posted this message in the forum dedicated to ASP.NET Forum bugs and discussions.)

Or, is this an error in your own application? If so, I will move this thread into theSQL Server and MSDE forum.|||Maybe I made a mistake.(I just met this error in my own server with asp.net environment)|||You've got mixed collations, this typically occurs when your underlying tables collation doesn't match the servers default collation. You need to specify the collation you want to use in the query. Look up COLLATE and DATABASE_DEFAULT.

It's also a common gotcha if you're using table vars, for the same reason, the same "COLLATE database_default" does the trick.