Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Visual Web Developer 2010 how to save textbox to SQL

gs1344gs1344 Member Posts: 2
I am new to Visual Web Developer Express. Something so simple not working ....
I connected to the SQL database
Created a webpage and simply added
2 textbox(s)
a gridview (works)
Submit button

When trying the app the Submit button appears to work but no data is sent to the SQL Database Obviously I have missed something in the Vb code behind the page. ?? Any help or thoughts appreciated. I have tried multiple searches and it should work!

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim SqlDataSource1 As New SqlDataSource()
Dim FailCode As New Table
Dim FailCodeDesc As New Table
Dim SqlDataSource As String = "Data Source=[my server name] ;Initial Catalog=[my database name] ;Integrated Security=True"

SqlDataSource1.InsertCommandType = SqlDataSourceCommandType.Text
SqlDataSource1.InsertCommand = "INSERT INTO ReachoutFailure (FailCode, FailDesc) Values (@FailCode, @FailDesc)"
SqlDataSource1.InsertParameters.Add("FailCode", TextBox1.Text)
SqlDataSource1.InsertParameters.Add("FailDesc", TextBox2.Text)

Dim rowsAffected As Integer = 0
rowsAffected = SqlDataSource1.Insert()
Catch ex As Exception
SqlDataSource1 = Nothing
End Try
If rowsAffected <> 1 Then

End If
End Sub

Sign In or Register to comment.