Public Shared Function InsertNewRecord(ByVal item1 As String, ByVal item2 As String, ByVal item3 As String) As Boolean' I deleted this declaration because I get my variables somewhere else
'Create the objects we need to insert a new record
Dim cnInsert As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\core.mdf;Integrated Security=True;User Instance=True")
Dim cmdInsert As New SqlCommand
Dim sSQL As New String("")
Dim iSqlStatus As Integer
'Set the stored procedure we're going to execute
sSQL = "Insertuniqueuser"
'Inline sql needs to be structured like so
'sSQL = "INSERT INTO YourTable(column1,column2,column3) VALUES('" & item1 & "','" & item2 & "','" & item3 & "')"
'Clear any parameters
cmdInsert.Parameters.Clear()
Try
'Set the SqlCommand Object Properties
With cmdInsert
'Tell it what to execute
.CommandText = sSQL 'Your sql statement if using inline sql
'Tell it its a stored procedure
.CommandType = CommandType.StoredProcedure 'CommandType.Text for inline sql
'If you are indeed using a stored procedure
'the next 3 lines pertain to you
'Now add the parameters to our procedure
'NOTE: Replace @value1.... with your parameter names in your stored procedure
'and add all your parameters in this fashion
.Parameters.AddWithValue("@badge", NewBadge)' There was item1 in place of NewBadge variable
.Parameters.AddWithValue("@Firstname", NewFirName)' There was item2 in place of Newfirname variable
.Parameters.AddWithValue("@Lastname", NewLasName)' There was item3 in place of NewLasName variable
.Parameters.AddWithValue("@Password", NewPassword)' I added this line
.Parameters.AddWithValue("@perm", NewPerm)' I added this line
'Set the connection of the object
.Connection = cnInsert
End With
'Now take care of the connection
HandleConnection(cnInsert)
'Set the iSqlStatus to the ExecuteNonQuery status of the insert (0 = success, 1 = failed)
iSqlStatus = cmdInsert.ExecuteNonQuery
'Now check the status
If Not iSqlStatus = 0 Then
'DO your failed messaging here
Return False
Else
'Do your success work here
Return True
End If
Catch ex As Exception
MsgBox(ex.Message, "Error")
Finally
'Now close the connection
HandleConnection(cnInsert)
End Try
End Function
The Added variables are public and I get their values prior to this function.
I also deleted the declare of item1, 2 and 3 at the top since I was getting the value from another place....but lets face it I may not understand What is going on. The stored procedure works i checked that. If I change what I change when i run the function nothing Happens please take a look and see what i am missing or not understanding. thank you for your time. If I do not delete the Declaration at the top i get this error,
Error 6 Argument not specified for parameter 'item1' of 'Public Shared Function InsertNewRecord(item1 As String, item2 As String, item3 As String) As Boolean'. C:\Documents and Settings\kschuett\My Documents\Visual Studio 2008\Projects\MAP1\MAP1\Newclass1.vb 183 9 MAP1
Respectfully
Aboch

New Topic/Question
Reply



MultiQuote




|