如何将文本框中的数据和带有存储过程的复选框插入SQL Server

时间:2022-12-26 15:42:25

This my code in vb.net, but when I run this code, it does not respond

这是我在vb.net中的代码,但是当我运行此代码时,它没有响应

If CheckBox5.Checked = True Then
     TextBox30.Enabled = True
     .Parameters.Add("MOD3", SqlDbType.NVarChar, 20).Value = TextBox30.Text
Else
     TextBox30.Enabled = False
End If

1 个解决方案

#1


If CheckBox5.Checked = True Then
         TextBox30.Enabled = True
         Dim cmd as new SqlCommand 
         cmd.CommandText = "your store procedure name here.."
         cmd.CommandType = CommandType.StoreProcedure
         cmd.Connection = con //your connection string object
         cmd.Parameters.Add("MOD3", SqlDbType.NVarChar, 20).Value = TextBox30.Text
         con.Open()
         cmd.ExecuteNonQuery()
         con.Close()
        Else
            TextBox30.Enabled = False
        End If

#1


If CheckBox5.Checked = True Then
         TextBox30.Enabled = True
         Dim cmd as new SqlCommand 
         cmd.CommandText = "your store procedure name here.."
         cmd.CommandType = CommandType.StoreProcedure
         cmd.Connection = con //your connection string object
         cmd.Parameters.Add("MOD3", SqlDbType.NVarChar, 20).Value = TextBox30.Text
         con.Open()
         cmd.ExecuteNonQuery()
         con.Close()
        Else
            TextBox30.Enabled = False
        End If