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
No comments:
Post a Comment