tehon3299
Well-known member
I have a problem when inserting data into an SQL table from VB.NET...My code is below. All I get in my SQL table is like spaces. Im trying to insert data from a textbox to an SQL table. Very simple but I dont know what I am doing wrong. Any suggestions??
Thanks
Code:
<script language="VB" runat="server">
Sub SubmitBtn_Click(sender As Object, e As EventArgs)
Dim MyCommand As SqlCommand
Dim MyConnection As SqlConnection
Dim MySQLDataAdapter as SqlDataAdapter
MyConnection = New SqlConnection("server=(local);database=checking;Trusted_Connection=yes")
Dim SessionCmd As String = "INSERT INTO tmTransactions (Description) VALUES (" & txtDesc.Text & ")"
MyCommand = New SqlCommand(SessionCmd, MyConnection)
MyCommand.Connection.Open()
Try
MyCommand.ExecuteNonQuery()
Catch Exp As SQLException
If Exp.Number = 2627
Else
End If
End Try
MyCommand.Connection.Close()
End Sub
Sub Page_Load(Sender As Object, E As EventArgs)
txtDesc.Text = ""
txtDate.Text = ""
End Sub
</script>
Thanks