I am new to asp.net. I was wondering if some one can help be out with something
this is what I have for my submit button
Me.txtprocess.Text.Insert()
all I am trying to do is when a user puts an entry in and click submit the entry is written over to a sql table.
Thanks in advanceJust do something like...
Dim strSQL As String ' SQL Statement
Dim cmd As New SqlClient.SqlCommand ' SQL Command
Dim strSubject As String ' Subject String
' Set the SQL connection to use for SQL Command
cmd.Connection = New SqlClient.SqlConnection("Persist Security Info=False;server=MyServer;database=MyDB;User ID=sa;Password=MyPassword")
' Add neccessary parameters to the SQL Command
cmd.Parameters.Add("@.MyData", txtMyData.Text)
' SQL UPDATE Statement
strSQL = "INSERT INTO MyTable (MyColumn) Values (MyData)"
' Try to catch any exceptions
Try
' if the SQL Connection is closed, open it
If SqlConn.State = ConnectionState.Closed Then
SqlConn.Open()
End If
' Set the SQL Command SQL Statement
cmd.CommandText = strSQL
' Execute the SQL Insert or Update
cmd.ExecuteNonQuery()
' Catch any exceptions
Catch ex As Exception
' Finally if it excepts or not
Finally
' If the SQL Connection is open, close it
If SqlConn.State = ConnectionState.Open Then
SqlConn.Close()
End If
End Try
Showing posts with label buttonme. Show all posts
Showing posts with label buttonme. Show all posts
Saturday, March 31, 2012
Submitting data to sql
Labels:
asp,
buttonme,
insert,
net,
somethingthis,
sql,
submit,
submitting,
text,
txtprocess
Subscribe to:
Posts (Atom)