| | |
INSERTING RECORD IN THE DATABASE(sURNAME AND TEMPLATE)
![]() |
•
•
Join Date: May 2008
Posts: 23
Reputation:
Solved Threads: 0
' Add template and surname to database. Returns added template ID.
Public Function AddTemplate(ByRef template As TTemplate) As Long
Dim da As New OleDbDataAdapter("select * from Biodata", connection)
Dim txtsurname As System.Windows.Forms.TextBox
txtsurname = New System.Windows.Forms.TextBox()
' Create SQL command containing ? parameter for BLOB.
da.InsertCommand = New OleDbCommand("INSERT INTO Biodata (surname,template) Values '" + txtsurname.Text + "',(?)", connection)
da.InsertCommand.CommandType = CommandType.Text
da.InsertCommand.Parameters.Add("@template", OleDbType.Binary, template.Size, "template")
da.InsertCommand.Parameters.Add("surname", OleDbType.VarChar, 50, "surname")
' Open connection
connection.Open()
' Fill DataSet.
Dim enroll As DataSet = New DataSet
da.Fill(enroll, "Biodata")
' Add a new row.
' Create parameter for ? contained in the SQL statement.
Dim newRow As DataRow = enroll.Tables("Biodata").NewRow()
newRow("template") = template.tpt
newRow("surname") = txtsurname.Text
enroll.Tables("Biodata").Rows.Add(newRow)
' Include an event to fill in the Autonumber value.
AddHandler da.RowUpdated, New OleDbRowUpdatedEventHandler(AddressOf OnRowUpdated)
' Update DataSet.
da.Update(enroll, "biodata")
'da.Update(enroll)
connection.Close()
' return ID
Return newRow("ID")
End FunctionI am having this error Command parameter[1] '' is invalid. in da.Update(enroll, "biodata")
Last edited by John A; Sep 1st, 2009 at 8:27 pm. Reason: added code tags
vb.net Syntax (Toggle Plain Text)
da.InsertCommand = New OleDbCommand("INSERT INTO Biodata (surname,template) Values (?,?)",connection) da.InsertCommand.CommandType = CommandType.Text da.InsertCommand.Parameters.Add("?", OleDbType.VarChar, 50, "surname") da.InsertCommand.Parameters.Add("?", OleDbType.Binary, template.Size, "template")
![]() |
Similar Threads
- vb6 update record in the database (Visual Basic 4 / 5 / 6)
- Pls need urgent respond to Inserting Record Into the Database (Visual Basic 4 / 5 / 6)
- Problem inserting Record to the database pls help (PHP)
- retrieving current record in database (Visual Basic 4 / 5 / 6)
- Code for Deleting a Record in a database?? (Visual Basic 4 / 5 / 6)
- Beginner: how to add new record into database??? (VB.NET)
- Criminal Record Database (Computer Science)
- link record in database with contactItem? (Visual Basic 4 / 5 / 6)
- how willl i be able to save a specific record into my database file in ms access (Java)
Other Threads in the VB.NET Forum
- Previous Thread: [HELP]sending many picture using socket programming
- Next Thread: how can i run code when click on send in outlook 2007?
Views: 305 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2005 2008 access ado.net application array arrays bal basic bindingsource browser c# center checkbox client code combobox connection control convert crystal crystalreport data database databind datagrid datagridview dataset datatable date datetimepicker design designer dissertation dissertations error excel file form gridview image images insert listview login loops mobile ms msaccess net objects openxml path port print printing problem read reports save search security serial server settings shutdown sms socket sorting sql statement studio syntax tagging tags textbox time timer type update upload user validation vb vb.net vb2008 view visual visual-studio visualbasic visualstudio2008 vs2008 web webbrowser windows winforms wpf xml






