 |
| View previous topic :: View next topic |
| Author |
Message |
teresaashfeld Newbie
Joined: 03 Aug 2005 Posts: 1
|
Posted: Aug 3rd, 2005 04:51 PM Post subject: Problems with Filling in TextBoxes in VB.net from SP |
|
|
Hi I am having difficulties getting an item into a textbox from my sp.
In the DAL my code is:
| Code: | Public Function GetEmployee(ByVal empID As Integer) As DataSet
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
Try
conn.Open()
Dim cmd As New SqlCommand("getselectemployee", conn)
With cmd
.Parameters.Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue
.Parameters.Add("@employeeid", SqlDbType.Int).Direction = ParameterDirection.Input
.Parameters("@employeeId").Value = empID
End With
Dim da As New SqlDataAdapter
da.SelectCommand = cmd
Dim ds As New DataSet
da.Fill(ds, "getselectemployee")
Return ds
da.Dispose()
Catch ex As Exception
Throw
Finally
conn.Close()
End Try
End Function |
Then I call it in my business layer:
:dgi: | Code: | Public Function GetEmployee(ByVal empId As Integer) As DataSet
Try
Return DALAdmin.GetEmployee(empId)
Catch ex As Exception
Throw
End Try
End Function | Then I call it in my form:
| Code: | Public Sub FillForm()
Try
Dim ds As DataSet
ds = BLLAdmin.GetEmployee(CType(Me.EmpId, Integer))
Dim mytable As DataTable
mytable = ds.Tables(0)
'this code will put the string in your textbox.
txtfn.Text = mytable.Rows(0).Item("E_FN")
txtNewFN.Text = mytable.Rows(0).Item(1) 'Do I need number or name?
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Data Reader Error")
End Try
End Sub |
The error I get is Line 1: Incorrect Syntax Near "GetSelectEmployee"
The sp working in sql. Not sure what to do. I really need help on this. Also if it would be more useful to use a datareader can someone give me an example?
Thanks in advance.
|
|
| Back to top |
|
jmcilhinney Freshman
Joined: 06 Jul 2005 Posts: 25 Location: Sydney, Australia
|
Posted: Aug 17th, 2005 05:48 AM Post subject: |
|
|
| Hopefully you've already fixed this but if not I believe you need to set the CommandType property of the SqlCommand to StoredProcedure, otherwise it is trying to interpret "getselectemployee" as an SQL statement. |
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|