Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Database & Reporting

Post new topic   Reply to topic
Problems with Filling in TextBoxes in VB.net from SP
View previous topic :: View next topic  
Author Message
teresaashfeld
Newbie


Joined: 03 Aug 2005
Posts: 1

PostPosted: Aug 3rd, 2005 04:51 PM    Post subject: Problems with Filling in TextBoxes in VB.net from SP Reply with quote

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.
Code:
Back to top
View user's profile Send private message MSN Messenger
jmcilhinney
Freshman


Joined: 06 Jul 2005
Posts: 25
Location: Sydney, Australia

PostPosted: Aug 17th, 2005 05:48 AM    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic