I'm trying to build what I though was going to be a very easy page but I'm missing the boat here somewhere.
First Name: Textbox
Last Name: Textbox
Submit Button
How do I bind the textbox to a table? I've read this and that, played around with GridView enabled insert, delete and update to the table and it works fine but I just want what I have above.
I'm very new to this stuff so please talk to me like I'm two.
Thanx
When you say bind the textbox to a table what exactly do you mean? Do you want the textbox values to be shown in a hidden datagrid upon submit? or do you want the values inserted into a access/sql db upon submit? or something totally different?
let me know,
Stue
I want the values inserted in db upon submit.
Thanx
Heres a sample of my insert function:
Function InsertEvent(ByVal strEventIDAsString,ByVal strEventDescAsString,ByVal strEventContentIDAsString)' Get "AppSettingName" from web.config(this has the db info ie table name, db, UN, PW, etc...that you entered)
Dim strConnAsString = ConfigurationManager.AppSettings("AppSettingName")
Dim sqlConnAs System.Data.SqlClient.SqlConnection =New System.Data.SqlClient.SqlConnection(strConn)
'Define your sql statement
Dim queryStringAsString ="INSERT INTO CMS_Log (User_Name, Event_ID, Date_Time, Description, Content_ID)" _
&"VALUES (@.User_Name, @.Event_ID, @.Date_Time, @.Description, @.Content_ID)"
Dim sqlCommandAs System.Data.SqlClient.SqlCommand =New System.Data.SqlClient.SqlCommand(queryString, sqlConn)'Example of returning the value of a function for parameter "@.User_Name"
sqlCommand.Parameters.Add(
'Example of returning the value of a string for parameter "@.Event_ID"
sqlCommand.Parameters.Add(
'Example of returning the value todays date for parameter "@.Date_Time"
sqlCommand.Parameters.Add(
'Example of returning the value of a textbox for parameter "@.Description"
sqlCommand.Parameters.Add(
sqlCommand.Parameters.Add(
New System.Data.SqlClient.SqlParameter("@.Content_ID", System.Data.SqlDbType.Int, 4,"Content_ID")).Value = strEventContentIDDim rowsAffectedAsInteger = 0sqlConn.Open()
TryrowsAffected = sqlCommand.ExecuteNonQuery
FinallysqlConn.Close()
EndTryReturn rowsAffectedEndFunction
HTH,
Stue
0 comments:
Post a Comment