TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Manuel Osorio
NA
2
1.8k
Search records in table using stored procedure in VB.NET
Jun 30 2015 7:35 PM
Hello
I want to search records in table from sql server using a stored procedure. I have in my form a datagridview and a textbox and If it's possible filter records in datagridview while I write in the textbox. But especially I want to use a stored procedure, please :)
I fill my datagridview with this code :
Public Function CargarDatos() As DataTable
Dim cnn As New SqlConnection(Configuration.ConfigurationManager.ConnectionStrings("Conexion").ToString())
Dim cmd As New SqlCommand("ObtenerAccesorios", cnn)
cmd.CommandType = CommandType.StoredProcedure
cnn.Open()
If cmd.ExecuteNonQuery Then
Dim dt As New DataTable
Dim da As New SqlDataAdapter(cmd)
da.Fill(dt)
Return dt
Else
Return Nothing
End If
cnn.Close()
End Function
The code in my windows form is:
Public Sub Cargar()
Dim func As New AccesoriosDAL
dt = func.CargarDatos
If dt.Rows.Count <> 0 Then
dgvListado.DataSource = dt
dgvListado.ColumnHeadersVisible = True
dgvListado.Columns("Estado").Visible = False
Linkinexistente.Visible = False
dgvListado.ClearSelection()
DesactivarEdiciongrid()
Else
dgvListado.DataSource = Nothing
dgvListado.ColumnHeadersVisible = False
Linkinexistente.Visible = True
End If
End Sub
Thank you so much and excuse me for my english :)
Reply
Answers (
1
)
scan documents and images
how to rowspan DataGridView in vb.net