Plz help me fast..
as my project submittion deadline is coming near..
when I execute the below block of vb.net code connected with sql server..
an error is generated namely "conversion failed nvarchar data type can not convert into type int"
and I get this error when drop down list data is moving to the sql database..
the structue of dropdown list is given to next of this code block..
on click event of an button 'rgstrUrslf'.....
Protected Sub btnRgstUrslf_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRgstUrslf.Click
Dim sqlstring As String = " insert into Rgstr_urslf (Fst_name, Last_name, Sch_no, Stream, Pswd, Cnfm_pwd, Email, Cont_no) values (@FstName, @LastName, @Stream, @SchNo, @Pswd, @CnfmPwd, @Email, @Cell)"
Dim cmd As New System.Data.SqlClient.SqlCommand()
cmd.Connection = con
cmd.CommandType = Data.CommandType.Text
cmd.CommandText = sqlstring
'cmd = New SqlCommand(sqlstring, cs)
Dim fstName As New SqlParameter("@FstName", SqlDbType.NVarChar, 15)
fstName.Value = txt1stName.Text.ToString()
cmd.Parameters.Add(fstName)
Dim lastName As New SqlParameter("@LastName", SqlDbType.NVarChar, 15)
lastName.Value = txtLastName.Text.ToString()
cmd.Parameters.Add(lastName)
Dim stream As New SqlParameter("@Stream", SqlDbType.NVarChar, 10)
stream.Value = lstStream.SelectedItem.ToString()
cmd.Parameters.Add(stream)
Dim schNo As New SqlParameter("@SchNo", SqlDbType.Int, 10)
schNo.Value = txtSchNo.Text.ToString()
cmd.Parameters.Add(schNo)
Dim pswd As New SqlParameter("@Pswd", SqlDbType.NVarChar, 15)
pswd.Value = txtPwd.Text.ToString()
cmd.Parameters.Add(pswd)
Dim cnfmPwd As New SqlParameter("@CnfmPwd", SqlDbType.NVarChar, 15)
cnfmPwd.Value = txtCnfmPwd.Text.ToString()
cmd.Parameters.Add(cnfmPwd)
Dim email As New SqlParameter("@Email", SqlDbType.NVarChar, 50)
email.Value = txtEmail.Text.ToString()
cmd.Parameters.Add(email)
Dim cont As New SqlParameter("@Cell", SqlDbType.Int, 10)
cont.Value = txtCell.Text.ToString()
cmd.Parameters.Add(cont)
Try
If Not con.State = ConnectionState.Open Then
con.Open()
End If
cmd.ExecuteNonQuery()
MsgBox("You have been sucessfully registered with us!", , "Registration")
Catch ex As Exception
'Dim errorMessage As String = "Error in registering user"
'errorMessage += ex.Message
MsgBox(ex.Message)
'Throw New Exception(errorMessage)
Finally
con.Close()
End Try
End Sub
structure of the dropdown list--
<html>
<body>
<asp:DropDownList ID="lstStream" runat="server" Height="22px" Width="229px">
<asp:ListItem>--Select your stream--</asp:ListItem>
<asp:ListItem>BCA</asp:ListItem>
<asp:ListItem>BBA</asp:ListItem>
<asp:ListItem>BSc</asp:ListItem>
<asp:ListItem>BCom</asp:ListItem>
<asp:ListItem>MBA</asp:ListItem>
</asp:DropDownList>
</body>
</html>