| | |
Can we use view Instead of Query
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Dec 2008
Posts: 11
Reputation:
Solved Threads: 0
This is my code.Here Instead of query string can i use view.
plz reply me.
Protected Sub btnchk_name_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnchk_name.Click
Dim str As String = "select ID from table1 where ID = '" & txtid.Text & "'"
Dim con As String = ConfigurationManager.AppSettings("preeconn")
Dim com As New SqlCommand(str, New SqlConnection(con))
com.Connection.Open()
Dim da As New SqlDataAdapter(str, con)
Dim dr As SqlDataReader
dr = com.ExecuteReader 'where sqldatareader ain't run without using
If Not dr.Read() Then
datagrid.datasource=com.executereader()
datagrid.databind()
End If
End Sub
plz reply me.
Protected Sub btnchk_name_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnchk_name.Click
Dim str As String = "select ID from table1 where ID = '" & txtid.Text & "'"
Dim con As String = ConfigurationManager.AppSettings("preeconn")
Dim com As New SqlCommand(str, New SqlConnection(con))
com.Connection.Open()
Dim da As New SqlDataAdapter(str, con)
Dim dr As SqlDataReader
dr = com.ExecuteReader 'where sqldatareader ain't run without using
If Not dr.Read() Then
datagrid.datasource=com.executereader()
datagrid.databind()
End If
End Sub
•
•
Join Date: Dec 2008
Posts: 104
Reputation:
Solved Threads: 18
Can you pls explain your objective first. I cant get it form you code. I have made some comments in your code. Can u pls explain those things
Protected Sub btnchk_name_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnchk_name.Click
Dim str As String = "select ID from table1 where ID = '" & txtid.Text & "'"
Dim con As String = ConfigurationManager.AppSettings("preeconn")
Dim com As New SqlCommand(str, New SqlConnection(con))
com.Connection.Open()
Dim da As New SqlDataAdapter(str, con)
' I cant see you using this object anywhere
Dim dr As SqlDataReader
dr = com.ExecuteReader 'where sqldatareader ain't run without using
' Are you sure this is the condition you really meant to give
If Not dr.Read() Then
datagrid.datasource=com.executereader()
' When you already have the result of your query in the sqldatareader object, why are u executing the same query the again, you could have used the same old object
datagrid.databind()
End If
End Sub
Protected Sub btnchk_name_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnchk_name.Click
Dim str As String = "select ID from table1 where ID = '" & txtid.Text & "'"
Dim con As String = ConfigurationManager.AppSettings("preeconn")
Dim com As New SqlCommand(str, New SqlConnection(con))
com.Connection.Open()
Dim da As New SqlDataAdapter(str, con)
' I cant see you using this object anywhere
Dim dr As SqlDataReader
dr = com.ExecuteReader 'where sqldatareader ain't run without using
' Are you sure this is the condition you really meant to give
If Not dr.Read() Then
datagrid.datasource=com.executereader()
' When you already have the result of your query in the sqldatareader object, why are u executing the same query the again, you could have used the same old object
datagrid.databind()
End If
End Sub
•
•
Join Date: Dec 2008
Posts: 11
Reputation:
Solved Threads: 0
•
•
•
•
Can you pls explain your objective first. I cant get it form you code. I have made some comments in your code. Can u pls explain those things
Protected Sub btnchk_name_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnchk_name.Click
Dim str As String = "select ID from table1 where ID = '" & txtid.Text & "'"
Dim con As String = ConfigurationManager.AppSettings("preeconn")
Dim com As New SqlCommand(str, New SqlConnection(con))
com.Connection.Open()
Dim da As New SqlDataAdapter(str, con)
' I cant see you using this object anywhere
Dim dr As SqlDataReader
dr = com.ExecuteReader 'where sqldatareader ain't run without using
' Are you sure this is the condition you really meant to give
If Not dr.Read() Then
datagrid.datasource=com.executereader()
' When you already have the result of your query in the sqldatareader object, why are u executing the same query the again, you could have used the same old object
datagrid.databind()
End If
End Sub
Actually my question is can we use views instead of query in our code.
![]() |
Similar Threads
- SQL query problem with WHERE clause (ASP)
- Problems using a php generator (PHP)
- Need Help connecting to a view (MS SQL)
- create a query in access from vb6 (Visual Basic 4 / 5 / 6)
- I need to trace or view that the stored proc is saving the data. (VB.NET)
- Create View syntax problem (Oracle)
- call resultset in join query (JSP)
- PHP Query, Make users login before accessing a movie? (PHP)
- Invision Power Board mysql error when trying to view newly created forums (PHP)
- Cant view Site with Changed DNS (Windows NT / 2000 / XP)
Other Threads in the ASP.NET Forum
- Previous Thread: Session Variable - Question
- Next Thread: file upload
| Thread Tools | Search this Thread |
.net 2.0 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser c# c#gridviewcolumn cac checkbox class commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier dataaccesslayer database datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formatdecimal forms formview gridview gudi homeedition iframe iis javascript jquery listbox microsoft mouse mssql multistepregistration news objects opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail rotatepage schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers





