Click here to Skip to main content
15,920,513 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i need how to write a select statements in stored procedure , and how to connect my vb.net WEB aplication


please help sir,
i need ur big help
Posted
Comments
Maciej Los 1-Apr-14 2:22am    
What have you done till now? Where are you stuck? What kind of issue do you have?
gnani_pal 1-Apr-14 3:13am    
Protected Sub insertbtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles insertbtn.Click
Dim request = New IDSRequest()
request.slnno = txtbxslnno.Text
request.empid = txtbxempid.Text
request.empno = txtbxempno.Text
request.empadress = txtbxadress.Text
Dim Response = DAOClass.manpulation(request)



Dim da As New SqlDataAdapter
Dim ds As New DataSet()


da.Fill(ds, "g")
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()

End Sub


this is in UI layer
and i write in logic in DAO layer ie;


Public Class DAOClass

Private Property GridView1 As Object

Public Shared Function manpulation(ByVal request As IDSRequest) As IDSResponse 'here parameters as REQUEST and returns as RESPONSE
Dim response = New IDSResponse()
Dim con As New SqlConnection()
Dim cmd As New SqlCommand()
Dim da As New SqlDataAdapter
Dim connectionstring As String
connectionstring = "server=SSPLDEV9;database=testing;User ID =sa; password=svt123;integrated security=false"
con = New SqlConnection(connectionstring)
con.Open()
cmd.CommandText = "Getemployeedetails"
cmd.CommandType = CommandType.StoredProcedure

'cmd.Parameters.AddWithValue("@slnno", )
cmd.Parameters.AddWithValue("@slnno", request.slnno)
cmd.Parameters.AddWithValue("@empid", request.empid)
cmd.Parameters.AddWithValue("@empno", request.empno)
cmd.Parameters.AddWithValue("@empadress", request.empadress)
cmd.Connection = con
cmd.ExecuteNonQuery()


con.Close()

Return response
End Function


here i got error
gnani_pal 1-Apr-14 5:32am    
now successfully i am doing inserting the values using stored procedures.
can you give any successions for delete the record using stored procedures and logic in the button click can i take separate stored procedure for delete

VB
Dim sqlConnection1 As New SqlConnection("Your Connection String")
Dim cmd As New SqlCommand
Dim reader As SqlDataReader

cmd.CommandText = "StoredProcedureName"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = sqlConnection1

sqlConnection1.Open()

reader = cmd.ExecuteReader()
' Data is accessible through the DataReader object here.
' Use Read method (true/false) to see if reader has records and advance to next record
' You can use a While loop for multiple records (While reader.Read() ... End While)
If reader.Read() Then
  someVar = reader(0)
  someVar2 = reader(1)
  someVar3 = reader("NamedField")
End If

sqlConnection1.Close()




and in sql server jus

SQL
CREATE PROCEDURE <pre lang="vb">StoredProcedureName
AS
SELECT * FROM table
GO</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900