Hi the first block of code upto line four is my connection portion.
I receive this exception error.
The name "txtStName" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
Code:
Dim strConn As String = "Data Source = (local); initial catalog = School; User ID = sa; password = 123;"
Dim cnSql As New SqlConnection(strConn)
Dim daSql As New SqlDataAdapter
Dim dsSql As New DataSet
this is insert button portion.
Private Sub btnStInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStInfo.Click
' Try
Dim strIns As String = "insert into StInfo (St_Name, St_Address, St_Age, St_Image) values ( '" & txtStName & "','" & txtStAdd & "', '" & txtStAge & "', '" & PictureBox1 & "')"
Dim cmdSql As New SqlCommand(strIns, cnSql)
cmdSql.CommandType = CommandType.Text
daSql.InsertCommand = cmdSql
daSql.InsertCommand.ExecuteNonQuery()
MsgBox("Record Inserted")
Clear()
' Catch ex As Exception
MsgBox("Record failed to be inserted")
' End Try
End SubI receive this exception error.
The name "txtStName" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.