参考我的上一个问题:" 连接未关闭.连接的当前状态是打开的 ".我正在尝试使用带有ASP.NET的vb.net进行注册表单.在解决了"关闭连接"问题之后.我有问题将数据插入我的数据库.当我尝试验证数据时,它给我一个错误消息:
必须声明标量变量"@User_Name"
有人可以帮我调试吗?谢谢
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Partial Class Register2
Inherits System.Web.UI.Page
'declaring connection string and command
'here we are extracting connection string from web.config file
Private con As New SqlConnection(ConfigurationManager.ConnectionStrings("MauriAuctions").ToString())
Private cmd As New SqlCommand()
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Try
cmd.Connection = con
'assigning connection to command
cmd.CommandType = CommandType.Text
'representing type of command
'cmd.CommandText = "INSERT INTO UserDetails (User_Name,Fname,Lname,Email,Password,Gender,Dob,Mobile,Address) values
' (@User_Name,@Fname,@Lname,@Email,@Password,@Gender,@Dob,@Mobile,@Address)";
cmd.CommandText = "INSERT INTO …Run Code Online (Sandbox Code Playgroud)