Click here to Skip to main content
15,889,281 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionhow to split an excel workbook into two in C# Pin
antony beula8-Oct-13 21:23
antony beula8-Oct-13 21:23 
AnswerRe: how to split an excel workbook into two in C# Pin
Richard MacCutchan8-Oct-13 23:24
mveRichard MacCutchan8-Oct-13 23:24 
Questionhey frnds help me out . Pin
Mr.VJ8-Oct-13 21:06
Mr.VJ8-Oct-13 21:06 
AnswerRe: hey frnds help me out . Pin
thatraja8-Oct-13 21:12
professionalthatraja8-Oct-13 21:12 
Questioni have prblrm in ajex auto complite text box need help plz Pin
eng.mohamed ali8-Oct-13 13:33
eng.mohamed ali8-Oct-13 13:33 
QuestionRe: i have prblrm in ajex auto complite text box need help plz Pin
Deflinek10-Oct-13 3:25
Deflinek10-Oct-13 3:25 
QuestionAsp.net Identity MVC5 + Nhibernate Pin
roscez7-Oct-13 6:47
roscez7-Oct-13 6:47 
QuestionProblem reading from sql server view Pin
Member 93288477-Oct-13 6:24
Member 93288477-Oct-13 6:24 
I'm having a problem reading data from a view built in a sql server db. I'm trying to use the same code to read from the view as I have used to read from sql server tables in the past through vb.net/asp, but it is not working. Vbcode bombs on the "sqlRead = sqlCmd.ExecuteReader()" line.


ASP
[code]
<pre lang="xml">&lt;%@ Page Language=&quot;VB&quot; AutoEventWireup=&quot;false&quot; CodeFile=&quot;Default.aspx.vb&quot; Inherits=&quot;_Default&quot; %&gt;

&lt;%@ Register assembly=&quot;System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&quot; namespace=&quot;System.Web.UI.WebControls&quot; tagprefix=&quot;asp&quot; %&gt;

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head runat=&quot;server&quot;&gt;
&lt;title&gt;Lifepoint Dashboard&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
#form1
{
height: 452px;
width: 856px;
}
#frmLPNT
{
height: 565px;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form id=&quot;frmLPNT&quot; runat=&quot;server&quot;&gt;
&lt;div&gt;

&lt;/div&gt;
&lt;asp:Image ID=&quot;Image1&quot; runat=&quot;server&quot; Height=&quot;90px&quot;
ImageUrl=&quot;~/images/IT&amp;SLogo.jpg&quot; Width=&quot;90px&quot; /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;

&lt;asp:SqlDataSource ID=&quot;dsLPNT&quot; runat=&quot;server&quot;
SelectCommand=&quot;SELECT [Incident_Number], [COID],[Vendor_Ticket_Number] , [Status], [Status_Reason],
[Priority], [Owner_Group], [Owner], [Assigned_Group], [Assignee],
[Product_Name], [First_Name], [Last_Name]
FROM [hca_incident_view]
WHERE (([Status] = &#39;In Progress&#39;) AND ([Company] = &#39;LifePoint&#39;) AND ([COID] = @COID))&quot;
ConnectionString=&quot;&lt;%$ ConnectionStrings:RemedyConnection %&gt;&quot;

DeleteCommand=&quot;&quot;
InsertCommand=&quot;&quot;
UpdateCommand=&quot;&quot;&gt;

&lt;SelectParameters&gt;
&lt;asp:ControlParameter ControlID=&quot;ddlCOID&quot; Name=&quot;COID&quot; PropertyName=&quot;Text&quot; Type=&quot;String&quot; /&gt;
&lt;/SelectParameters&gt;
&lt;/asp:SqlDataSource&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;asp:DropDownList ID=&quot;ddlCOID&quot; runat=&quot;server&quot; onSelectedIndexChanged=&quot;ddlCOID_SelectedIndexChanged&quot; AutoPostBack=&quot;true&quot; Height=&quot;22px&quot; Width=&quot;331px&quot;&gt;

&lt;/asp:DropDownList&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;asp:GridView ID=&quot;GridView1&quot; runat=&quot;server&quot; CellPadding=&quot;4&quot; ForeColor=&quot;#333333&quot;
GridLines=&quot;None&quot;&gt;
&lt;RowStyle BackColor=&quot;#F7F6F3&quot; ForeColor=&quot;#333333&quot; /&gt;
&lt;FooterStyle BackColor=&quot;#5D7B9D&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&gt;
&lt;PagerStyle BackColor=&quot;#284775&quot; ForeColor=&quot;White&quot; HorizontalAlign=&quot;Center&quot; /&gt;
&lt;SelectedRowStyle BackColor=&quot;#E2DED6&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;#333333&quot; /&gt;
&lt;HeaderStyle BackColor=&quot;#5D7B9D&quot; Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&gt;
&lt;EditRowStyle BackColor=&quot;#999999&quot; /&gt;
&lt;AlternatingRowStyle BackColor=&quot;White&quot; ForeColor=&quot;#284775&quot; /&gt;

&lt;/asp:GridView&gt;


&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;

&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;div style=&quot;margin-left: 280px&quot;&gt;


&lt;br /&gt;


&lt;/div&gt;


&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>

[/code]


VB.net
[code]
<pre lang="vb">Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient
Imports System.Data.DataRowView






Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub frmLPNT_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles frmLPNT.Load
Me.ddlCOID.Items.Add(&quot;Select LifePoint Facility...&quot;)
Me.ddlCOID.Items.Add(&quot;Acadian Regional Medical Center&quot;)
Me.ddlCOID.Items.Add(&quot;Ashley Valley Medical Center&quot;)
Me.ddlCOID.Items.Add(&quot;Ashley Valley Medical Center&quot;)




Me.ddlCOID.Items.Add(&quot;Bolivar Medical Center&quot;)
Me.ddlCOID.Items.Add(&quot;Colorado Plains Medical Center&quot;)
Me.ddlCOID.Items.Add(&quot;Ennis Regional Medical Center&quot;)

Me.ddlCOID.Items.Add(&quot;Valley View Medical Center&quot;)
Me.ddlCOID.Items.Add(&quot;Lake Havasu Regional Medical Center&quot;)
Me.ddlCOID.Items.Add(&quot;Memorial Medical Center Resources&quot;)
Me.ddlCOID.Items.Add(&quot;Los Alamos Medical Center&quot;)
Me.ddlCOID.Items.Add(&quot;Memorial Hospital of Martinsville&quot;)
Me.ddlCOID.Items.Add(&quot;Minden Medical Center&quot;)
Me.ddlCOID.Items.Add(&quot;Northeastern Nevada Regional&quot;)
Me.ddlCOID.Items.Add(&quot;Palestine Regional Medical Center&quot;)
Me.ddlCOID.Items.Add(&quot;Parkview Regional Hospital&quot;)

Me.ddlCOID.Items.Add(&quot;LPNT CORP&quot;)
End Sub

Public Sub ddlCOID_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCOID.SelectedIndexChanged
Dim strCOID As String = TryCast(sender, DropDownList).SelectedValue
Select Case strCOID
Case &quot;Acadian Regional Medical Center&quot;
strCOID = &quot;02751&quot;
Case &quot;Andalusia Regiona Hospital&quot;
strCOID = &quot;05356&quot;
Case &quot;Ashley Valley Medical Center&quot;
strCOID = &quot;05424&quot;


Case &quot;Bolivar Medical Center&quot;
strCOID = &quot;02723&quot;
Case &quot;Colorado Plains Medical Center&quot;
strCOID = &quot;02740&quot;
Case &quot;Ennis Regional Medical Center&quot;
strCOID = &quot;02750&quot;

Case &quot;Valley View Medical Center&quot;
strCOID = &quot;02757&quot;
Case &quot;Lake Havasu Regional Medical Center&quot;
strCOID = &quot;02758&quot;
Case &quot;Memorial Medical Center Resources&quot;
strCOID = &quot;02765&quot;
Case &quot;Los Alamos Medical Center&quot;
strCOID = &quot;02779&quot;
Case &quot;Memorial Hospital of Martinsville&quot;
strCOID = &quot;02781&quot;
Case &quot;Minden Medical Center&quot;
strCOID = &quot;02782&quot;
Case &quot;Northeastern Nevada Regional&quot;
strCOID = &quot;02784&quot;
Case &quot;Palestine Regional Medical Center&quot;
strCOID = &quot;02785&quot;
Case &quot;Parkview Regional Hospital&quot;
strCOID = &quot;02790&quot;
Case &quot;LPNT CORP&quot;
strCOID = &quot;05433&quot;

End Select
&#39;MsgBox(strCOID)






Dim sqlConn As New SqlConnection(ConfigurationManager.ConnectionStrings(&quot;RemedyConnection&quot;).ConnectionString)

Dim sSql As System.Xml.Linq.XElement = &lt;sql&gt; SELECT [Incident_Number], [COID],[Vendor_Ticket_Number] , [Status], [Status_Reason],[Priority], [Owner_Group], [Owner], [Assigned_Group], [Assignee], [Product_Name], [First_Name], [Last_Name] FROM ([hca_incident_view]) WHERE ([Status] = &#39;In Progress&#39;) AND ([Company] = &#39;LifePoint&#39;) AND ([COID] = &#39;&lt;%= strCOID %&gt;&#39;)
&lt;/sql&gt;






&#39;This code executes your sql command



Dim sqlCmd As New SqlCommand(sSql.Value, sqlConn)
Dim sqlRead As SqlDataReader

If sqlConn.State &lt;&gt; ConnectionState.Open Then
sqlConn.Open()
End If

sqlRead = sqlCmd.ExecuteReader()
sqlRead.Read()
sqlRead.Close()

&#39;MsgBox(&quot;Connected&quot;)




&#39;Close the connection
sqlConn.Close()



For i As Int16 = 0 To Me.ddlCOID.Items.Count - 2
For j As Int16 = Me.ddlCOID.Items.Count - 1 To i + 1 Step -1
If Me.ddlCOID.Items(i).ToString = Me.ddlCOID.Items(j).ToString Then
Me.ddlCOID.Items.RemoveAt(j)
End If
Next
Next

End Sub

End Class</pre>

[/code]
AnswerRe: Problem reading from sql server view Pin
Richard Deeming7-Oct-13 7:22
mveRichard Deeming7-Oct-13 7:22 
GeneralRe: Problem reading from sql server view Pin
Member 93288479-Oct-13 15:39
Member 93288479-Oct-13 15:39 
QuestionEncrypting Parameter value from Right Click Source Code Pin
alok00007-Oct-13 0:13
alok00007-Oct-13 0:13 
QuestionHow to bind multiple rows from data table to single row in Gridview Pin
priyaahh6-Oct-13 23:14
priyaahh6-Oct-13 23:14 
Questionhow to increase performance Pin
antony beula6-Oct-13 21:36
antony beula6-Oct-13 21:36 
AnswerRe: how to increase performance Pin
thatraja6-Oct-13 22:54
professionalthatraja6-Oct-13 22:54 
AnswerRe: how to increase performance Pin
ais076-Oct-13 23:00
ais076-Oct-13 23:00 
SuggestionRe: how to increase performance Pin
Richard Deeming7-Oct-13 1:44
mveRichard Deeming7-Oct-13 1:44 
QuestionHow call secure web service using Jquery Pin
ais076-Oct-13 19:41
ais076-Oct-13 19:41 
QuestionPrincipalContext & UserPrincipal Pin
JD866-Oct-13 19:22
JD866-Oct-13 19:22 
QuestionHey Friends..plz help me out... Pin
Member 103122576-Oct-13 18:57
Member 103122576-Oct-13 18:57 
AnswerRe: Hey Friends..plz help me out... Pin
Member 103122576-Oct-13 18:59
Member 103122576-Oct-13 18:59 
AnswerRe: Hey Friends..plz help me out... Pin
Blikkies6-Oct-13 20:27
professionalBlikkies6-Oct-13 20:27 
AnswerRe: Hey Friends..plz help me out... Pin
ais076-Oct-13 20:39
ais076-Oct-13 20:39 
SuggestionRe: Hey Friends..plz help me out... Pin
Richard Deeming7-Oct-13 1:33
mveRichard Deeming7-Oct-13 1:33 
AnswerRe: Hey Friends..plz help me out... Pin
Richard Deeming7-Oct-13 1:38
mveRichard Deeming7-Oct-13 1:38 
AnswerRe: Hey Friends..plz help me out... Pin
blachsmith7-Oct-13 22:54
blachsmith7-Oct-13 22:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.