Showing An Image Based On A Boolean Condition
I have a table object attached to a dataset,
One of the columns is based on a boolean value(bit field) from the database.
I have a check picture and an unchecked picture.
How can I show the selected image based on the result?
links or ideas welcome
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Incorrect Syntax Near 'm'. An Expression Of Non-boolean Type Specified In A Context Where A Condition Is Expected, Near 'type'
This is nutty. I never got this error on my local machine. The only lower case m in the sql is by near the variable Ratingsum like in line 59. [SqlException (0x80131904): Incorrect syntax near 'm'.An expression of non-boolean type specified in a context where a condition is expected, near 'type'.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +925466 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800118 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932 System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) +196 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +269 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135 view_full_article.btnRating_Click(Object Src, EventArgs E) +565 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746</pre></code> Here is my button click sub in its entirety: 1 Sub btnRating_Click(ByVal Src As Object, ByVal E As EventArgs) 2 'Variable declarations... 3 Dim articleid As Integer 4 articleid = Request.QueryString("aid") 5 Dim strSelectQuery, strInsertQuery As String 6 Dim strCon As String 7 Dim conMyConnection As New System.Data.SqlClient.SqlConnection() 8 Dim cmdMyCommand As New System.Data.SqlClient.SqlCommand() 9 Dim dtrMyDataReader As System.Data.SqlClient.SqlDataReader 10 Dim MyHttpAppObject As System.Web.HttpContext = _ 11 System.Web.HttpContext.Current 12 Dim strRemoteAddress As String 13 Dim intSelectedRating, intCount As Integer 14 Dim Ratingvalues As Decimal 15 Dim Ratingnums As Decimal 16 Dim Stars As Decimal 17 Dim Comments As String 18 Dim active As Boolean = False 19 Me.lblRating.Text = "" 20 'Get the user's ip address and cast its type to string... 21 strRemoteAddress = CStr(MyHttpAppObject.Request.UserHostAddress) 22 'Build the query string. This time check to see if IP address has already rated this ID. 23 strSelectQuery = "SELECT COUNT(*) As RatingCount " 24 strSelectQuery += "FROM tblArticleRating WHERE Itemid=" & articleid 25 strSelectQuery += " AND ip = '" & strRemoteAddress & "'" 26 'Open the connection, and execute the query... 27 strCon = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("sqlConnectionString").ConnectionString 28 conMyConnection.ConnectionString = strCon 29 conMyConnection.Open() 30 cmdMyCommand.Connection = conMyConnection 31 cmdMyCommand.CommandType = System.Data.CommandType.Text 32 cmdMyCommand.CommandText = strSelectQuery 33 intCount = cmdMyCommand.ExecuteScalar() 34 intSelectedRating = Int(Me.rbRating.Text) 35 conMyConnection.Close() 36 'Close the connection to release these resources... 37 38 If intCount = 0 Then 'The user hasn't rated the article 39 'before, so perform the insert... 40 strInsertQuery = "INSERT INTO tblArticleRating (rating, ip, itemID, comment, active) " 41 strInsertQuery += "VALUES (" 42 strInsertQuery += intSelectedRating & ", '" 43 strInsertQuery += strRemoteAddress & "', " 44 strInsertQuery += articleid & ", '" 45 strInsertQuery += comment.Text & "', '" 46 strInsertQuery += active & "'); " 47 cmdMyCommand.CommandText = strInsertQuery 48 conMyConnection.Open() 49 cmdMyCommand.ExecuteNonQuery() 50 conMyConnection.Close() 51 Me.lblRating.Text = "Thanks for your vote!" 52 Comments = comment.Text.ToString 53 54 If Len(Comments) > 0 Then 55 emailadmin(comment.Text, articleid) 56 End If 57 'now update the article db for the two values but first get the correct ratings for the article 58 strSelectQuery = _ 59 "SELECT SUM(rating) As RatingSum, COUNT(*) As RatingCount " 60 strSelectQuery += "FROM tblArticleRating WHERE Itemid=" & articleid 61 conMyConnection.Open() 62 cmdMyCommand.CommandText = strSelectQuery 63 dtrMyDataReader = cmdMyCommand.ExecuteReader() 64 dtrMyDataReader.Read() 65 Ratingvalues = Convert.ToDecimal(dtrMyDataReader("RatingSum").ToString) 66 Ratingnums = Convert.ToDecimal(dtrMyDataReader("RatingCount").ToString) 67 Stars = Ratingvalues / Ratingnums 68 conMyConnection.Close() 69 'Response.Write("Values: " & Ratingvalues) 70 'Response.Write("Votes: " & Ratingnums) 71 72 UpdateRating(articleid, Stars, Ratingnums) 73 Else 'The user has rated the article before, so display a message... 74 Me.lblRating.Text = "You've already rated this article" 75 End If 76 strSelectQuery = _ 77 "SELECT SUM(rating) As RatingSum, COUNT(*) As RatingCount " 78 strSelectQuery += "FROM tblArticleRating WHERE Itemid=" & articleid 79 conMyConnection.Open() 80 cmdMyCommand.CommandText = strSelectQuery 81 dtrMyDataReader = cmdMyCommand.ExecuteReader() 82 dtrMyDataReader.Read() 83 Ratingvalues = Convert.ToDecimal(dtrMyDataReader("RatingSum").ToString) 84 Ratingnums = Convert.ToDecimal(dtrMyDataReader("RatingCount").ToString) 85 Stars = Ratingvalues / Ratingnums 86 If (Ratingnums = 1) And (Stars <= 1) Then 87 lblRatingCount.Text =" (" & (String.Format("{0:f2}", Stars)) & ") / " & dtrMyDataReader("RatingCount") & " Vote" 88 ElseIf (Ratingnums = 1) And (Stars > 1) Then 89 lblRatingCount.Text = " (" & (String.Format("{0:f2}", Stars)) & ") / " & dtrMyDataReader("RatingCount") & " Vote" 90 ElseIf (Ratingnums > 1) And (Stars <= 1) Then 91 lblRatingCount.Text =" (" & (String.Format("{0:f2}", Stars)) & ") / " & dtrMyDataReader("RatingCount") & " Votes" 92 ElseIf (Ratingnums > 1) And (Stars > 1) Then 93 lblRatingCount.Text = " (" & (String.Format("{0:f2}", Stars)) & ") / " & dtrMyDataReader("RatingCount") & " Votes" 94 End If 95 96 'Response.Write(String.Format("{0:f2}", Stars)) 97 'Response.Write("Values: " & Ratingvalues) 98 'Response.Write("Votes: " & Ratingnums) 99 If (Stars > 0) And (Stars <= 0.5) Then 100 Me.Rating.ImageUrl ="./images/rating/05star.gif" 101 ElseIf (Stars > 0.5) And (Stars < 1.0) Then 102 Me.Rating.ImageUrl = "./images/rating/05star.gif" 103 ElseIf (Stars >= 1.0) And (Stars < 1.5) Then 104 Me.Rating.ImageUrl = "./images/rating/1star.gif" 105 ElseIf (Stars >= 1.5) And (Stars < 2.0) Then 106 Me.Rating.ImageUrl = "./images/rating/15star.gif" 107 ElseIf (Stars >= 2.0) And (Stars < 2.5) Then 108 Me.Rating.ImageUrl = "./images/rating/2star.gif" 109 ElseIf (Stars >= 2.5) And (Stars < 3.0) Then 110 Me.Rating.ImageUrl = "./images/rating/25star.gif" 111 ElseIf (Stars >= 3.0) And (Stars < 3.5) Then 112 Me.Rating.ImageUrl = "./images/rating/3star.gif" 113 ElseIf (Stars >= 3.5) And (Stars < 4.0) Then 114 Me.Rating.ImageUrl = "./images/rating/35star.gif" 115 ElseIf (Stars >= 4.0) And (Stars < 4.5) Then 116 Me.Rating.ImageUrl = "./images/rating/4star.gif" 117 ElseIf (Stars >= 4.5) And (Stars < 5.0) Then 118 Me.Rating.ImageUrl = "./images/rating/45star.gif" 119 ElseIf (Stars >= 4.5) And (Stars <= 5.0) Then 120 Me.Rating.ImageUrl = "./images/rating/5star.gif" 121 End If 122 dtrMyDataReader.Close() 123 conMyConnection.Close() 124 End Sub If you want to reduplicate the error, click over here and try to submit a rating: http://www.link-exchangers.com/view_full_article.aspx?aid=51 Thanks for helping me figure this out.
View Replies !
View Related
SQL Report Image Not Showing
When generating a SQL report, external images from a Sharepoint image library are not shown (red X). An unattended execution account is set correctly, the image exists. I have tried with setting the UseSessionCookies to true/false. nothing seems to work. Anyone any ideas wath else I can try?
View Replies !
View Related
Showing Image Using Image Url
Hi, I need to show images in the report based on the urls from the db. The images are stored within a folder and not in the db (only the url in db). I couldnt find any way to give an url in the report and show the image. I'm stuck here , could you please help? Thanks, Sonu.
View Replies !
View Related
Why Isnt My Image Showing In My Gridview
hi, i have created a webpage so that my images are stored in a database, however i have linked it to a gridview but when i go to run the page it doesnt show the actual picture saved in the database. in the gridview row it does recognise that there is a picture present but all it shows on the web page is that little x that appears when it cant view a picture, does anyone know how i can solve this problem? i will paste my code behind page and aspx page. thanks for any advice given, code behind pageProtected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ds As New Data.DataSetDim da As Data.SqlClient.SqlDataAdapter Dim strSQL As String strSQL = "Select imgId,imgTitle from Image"Dim connString As String = (ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)da = New Data.SqlClient.SqlDataAdapter(strSQL, connString) da.Fill(ds) ds.Tables(0).Columns.Add("imgFile")For Each tempRow As Data.DataRow In ds.Tables(0).Rows tempRow.Item("imgFile") = ("imgGrab.aspx?id=" & tempRow.Item("imgID")) Next imgGrid.DataSource = ds imgGrid.DataBind() End Sub aspx page <form id="form1" runat="server"> <div> </div><asp:GridView ID="imgGrid" runat="server" AutoGenerateColumns="False" Height="286px" Width="564px"> <Columns><asp:BoundField DataField="imgTitle" HeaderText="imgTitle" SortExpression="imgTitle" /> <asp:ImageField DataImageUrlField="imgFile" HeaderText="Picture"> </asp:ImageField> </Columns> </asp:GridView></form> </body> </html>
View Replies !
View Related
Incrementing Based On Condition
Hi, I am facing a challenge and hope some one can help me with the query. I have a school. School have classrooms. Classrooms are divided into various sections (Section A, Section B and so on) . Sections have subsections. Every student is allocated a rollnumber in that section.(Subsection is just for dividng the sections. it has no other use.) Now the student is given a choice to specify his own roll( DesiredRoll) in that section. If two children select the same rollno, then the system internally allocates a trackingno.(There can be multiple roll no as these are allocated manually by admin). Let me demonstrate this: So when the first entry is made in the db, and let us say that the section to be allocated is A, RollNo is 1 and the DesiredRoll is 1 Student 1 Section A Subsection 1 Roll No 1 DesiredRoll 1 TrackingNo 0 The second entry is made in the db and let us say the section to be allocated is A, RollNo is 2 and the DesiredRoll is 2 Student 2 Section A Subsection 1 Roll No 2 DesiredRoll 2 TrackingNo 0 Now let us say there is a 3rd entry the section to be allocated is A, RollNo is 3 but the DesiredRoll is 1. Now since the DesiredRoll has already been taken, we will allocate the DesiredRoll 1, however now the trackingNo will be 1 Let us say there is a 4th entry is made, the section to be allocated is A, RollNo is 4 but the DesiredRoll is again 1. Now since the DesiredRoll has already been taken, we will allocate the DesiredRoll 1, however now the trackingNo will be 2 Similarly this logic will work for different sections. How will I write a query so that I can detect this scenario and increment the tracking no or allocate a tracking no of 0 if there is a new entry made in that section The structure of the table is as follows: IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Student]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Student]( [RID] [int] NOT NULL, [Class] [int] NULL, [Section] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [SubSection] [int] NULL, [RollNo] [int] NULL, [DesiredRoll] [int] NULL, [TrackingNo] [int] NULL ) END GO INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (1, 1, N'A', 1, 1, 1, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (2, 1, N'A', 1, 2, 2, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (3, 1, N'A', 1, 3, 1, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (4, 1, N'A', 1, 4, 1, 2) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (5, 1, N'A', 12, 3, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (6, 1, N'A', 12, 4, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (7, 1, N'B', 5, 1, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (8, 1, N'B', 5, 2, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (9, 1, N'B', 5, 3, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (10, 1, N'B', 10, 1, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (11, 1, N'B', 10, 2, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (12, 1, N'B', 10, 3, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (13, 1, N'B', 11, 1, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (14, 1, N'B', 11, 2, 0, 0) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo]) VALUES (15, 1, N'B', 11, 3, 0, 0) Thanks
View Replies !
View Related
JOIN Based On LIKE Condition
I'm trying to join two tables based on a like condition. The first table contains the full IP, e.g. '166.27.12.24' and the second contains a 2 octet range, e.g. '166.27', which I need to join. Table 1 -> TRAFFIC (Time, SourceIP) Table 2 -> IP_ROSTER (IP2OctetRange, Administrator) I've tried the following, but it does not seem to work: SELECT TOP 100 SOURCE_IP, r.IP2OctetRange, r.Administrator FROM TRAFFIC LEFT JOIN IP_ROSTER AS r ON SOURCE_IP LIKE RTRIM(LTRIM(IP2OctetRange))+'%'
View Replies !
View Related
Returns TABLE Based On A Condition
HI all,In SQL Server, i have a function which will return a table. likecreate function fn_test (@t int) returns table asreturn (select * from table)now i want the function to retun the table based on some condition like belowcreate function fn_test(@t int) returns table asif @t = 1 return (select * from table1)else return (select * from table2)It is not working for me. Please give me your suggesstions. It's very urgent.Thank you in advance....
View Replies !
View Related
How To Write Trigger Based On Certain Condition
One of my table called as 'customertable' contains following fields customername, emailid, subscriptionendperiod Example records are: david, david@john.com, 12/20/2005(mm/dd/yyyy format). My question is that: Just one month before subscriptionendperiod that is on 11/20/2005(mm/dd/yyyy) an automatic email should go to david@john.com with the message 'Your subscription period ends on 12/20/2005' How to write trigger for this. Please Note : No ASP code is invloved in this. Only MSSQL coding to be done. Regards
View Replies !
View Related
Condition Joins Based On Parameters
I'm using SQL Server 2005 Reporting Services. Apologies if this is in the wrong area. I'm not sure if it's possible but what I want to do is join table dimFactor to factMedia using different fields dependent on the partameter value. i.e from FactMedia fm... if parameter value = 1 INNER JOIN dimFactor df ON df.FactorID = fm.AgeGroup_ID if parameter value = 2 INNER JOIN dimFactor df ON df.FactorID = fm.Gender_ID and so on.. Can this be done and if so, how?? I've tried using CASE statements but it's not having any of it. Help please!
View Replies !
View Related
Reordering Rows Based On A Condition
Hi, I have two tables : Students and StuHistory. The structure of the Student table is as follows : IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Student]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[Student]( [RID] [int] NOT NULL, [Class] [int] NULL, [Section] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [SubSection] [int] NULL, [RollNo] [int] NULL, [DesiredRoll] [int] NULL, [TrackingNo] [int] NULL, [Original_rollno] [int] NULL, [StudentStatus] [int] NULL ) END GO A section has subsections where students are allocated rollno's. Every student has a unique roll no in that subsection. However he is also given a choice to enter his desired roll no. If more than one student choose the same desired roll no in that subsection/section, there is a [TrackingNo] field that then starts keeping a count. For the first unique desired roll no in that subsection/section the tracking no is always 0. [StudentStatus] represents the following : (-1 for deleted, 0 for edited, 1 for newly inserted). After every fortnight, i have to run a batchquery that does the following: 1. all students marked with -1 are moved to a table called StuHistory which has the same structure as that of Student. 2. Now oncethe -1 status students are moved, there will be a gap in the roll no. I want to reallocate the rollnos now, where rollnos = desired roll no taking into consideration the trackingno So if 4 students have chosen the desired roll no as 5 and their current roll no is scattered in a subsection lets say 7, 10, 14,16, then while rearranging they will be together(grouped by subsection/section) and will be allocated roll no's 5,6,7,8. The other students will be moved down based on their desired roll nos. Over here i have to also fill the gaps caused because of the students who were deleted. How do i write query for this? I have been struggling. I thought of posting this as a new post as it was mixed in the previous post. Script : INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (1, 1, N'A', 1, 1, 1, 0, 0, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (2, 1, N'A', 1, 2, 2, 0, 0, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (3, 1, N'A', 1, 3, 1, 1,0,1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (4, 1, N'A', 12, 1, 1, 0,-1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (5, 1, N'A', 12, 2, 1, 1, 0, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (6, 1, N'A', 12, 3, 2, 0, 0, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (7, 1, N'B', 5, 1, 3, 0, 0, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (8, 1, N'B', 5, 2, 3, 1, 0 ,1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (9, 1, N'B', 5, 3, 3, 2, 0, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (10, 1, N'B', 5, 4, 2, 0, 0, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (11, 1, N'B', 5, 5, 2, 1, 0, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (12, 1, N'B', 10, 1, 1, 0, 0, 1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (13, 1, N'B', 10, 2, 1, 1, 0, 1 ) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (14, 1, N'B', 10, 3, 1, 2, 0, -1) INSERT [dbo].[Student] ([RID], [Class], [Section], [SubSection], [RollNo], [DesiredRoll], [TrackingNo], [Original_rollno], [StudentStatus] ) VALUES (15, 1, N'B', 10, 4, 2, 0, 0, 1) Thanks.
View Replies !
View Related
Insert Into Temp Table Based On If Condition
hello all,this might be simple:I populate a temp table based on a condition from another table:select @condition = condition from table1 where id=1 [this will giveme either 0 or 1]in my stored procedure I want to do this:if @condition = 0beginselect * into #tmp_tablefrom products pinner joinsales s on p.p_data = s.p_dataendelsebeginselect * into #tmp_tablefrom products pleft joinsales s on p.p_data = s.p_dataendTha above query would not work since SQL thinks I am trying to use thesame temp table twice.As you can see the major thing that gets effected with the condictionbeing 0/1 is the join (inner or outer). The actual SQL is much biggerwith other joins but the only thing changing in the 2 sql's is the joinbetween products and sales tables.any ideas gurus on how to use different sql's into temp table based onthe condition?thanksadi
View Replies !
View Related
Check Certain Row Of Record Based On Special Condition
let say i have such data in table ------------------------------- Number | Descriptions 5 | xxxxxxx 4 | xxxxxxx 3 | xxxxxxx 2 | xxxxxxx 1 | xxxxxxx 0 | xxxxxxx <- 5 | xxxxxxx <- 4 | xxxxxxx anyway to select 0 | xxxxxxx 5 | xxxxxxx out? based on the number of next row is 5, and current number is 0. because i need to description data.
View Replies !
View Related
How To Make Table Row Invisible Based On Certain Condition
HI I have the following scenario in my report. -The data is displayed in a table -The table groups by one field -Each table row calls a subreport -There is about 6 paramaters in the report -The last paramater of the list of paramters is a multivalue paramater and based on what is selected in the list the corresponding subreport must be shown. -So i use a custom vbscript funtion to determine if a specific value was selected or not. This functionality is working fine. My problem is if the user does not select all the values in the multi select then i want to make the row invisble and remove the whitespace so that there is not a gap between the other subreports which is shown. I can make the subreport invisible inside the row but there is still the white space which does not display very nicly. How can i make the row invisible if the vbscript function that is called returns a false value? Here is the funtion I call -> Code.InArray("ValueToSearchFor", Parameters!MultiValueDropDown.Value) The Function returns a true or false. Thanks.
View Replies !
View Related
Getting Column Names And Its Values Based On Condition
Hi, I have a table as follows Table Master { Id varchar(20), Cat1 datetime, Cat2 datetime, Cat3 datetime, Cat4 datetime } and the data in the table is as follows Table Master { Id cat1 cat2 cat3 cat4 ----------------------------------------------- 1 d11 null d13 d14 2 d21 d22 d23 d24 3 NULL d32 d33 d34 4 d41 d42 NULL NULL } I want to retrive column names and its values wheb the ID matches to some value. Can any one please let me know how to do this? Thanks alot ~Mohan
View Replies !
View Related
How To Generate Condition Based Aggregate/summary Data
Hi I have a source table with App_Id, App_Type , Tier_Type, Date_Id as columns. I have a destination table with Date_Id, Total_App_Count, Booked_App_Type_Count, Approved_App_Type_Count columns. I need to count the Total number of records , count of records with App_Type = "Booked" and count of records with App_Type = "Approved" and populate in my destination table. What all the steps i need to create in SSIS to get this results ? Thanks Kumaran
View Replies !
View Related
How To Make Subreport Visible Based On Parameter Condition?
Hi, I have a subreport added to the main report and I want to make this report visible only when the parameter value is met. Ex, I have a parameter CustName in the main report and want to show the subreport when the custName = xxxxx. There reports are parameter driven not data driven reports. Any help is greatly appreciated. Thanks, Sirisha
View Replies !
View Related
Adding A Column Name To A Table In Each Of The Databases Based On A Condition
i have the folowing databases DB1,DB2,DB3,D4,DB5........ i have to loop through each of the databases and find out if the database has a table with the name 'Documents'( like 'tbdocuments' or 'tbemplyeedocuments' and so on......) If the tablename having the word 'Documents' is found in that database i have to add a column named 'IsValid varchar(100)' against that table in that database and there can be more than 1 'Documents' table in a database. can someone show me the script to do it? Thanks.
View Replies !
View Related
Inserting Values Intoto Only Column Based On A Condition
Hi, I have at table as foolows Table Cat3 { ID, Update datetime } and also have a master table as follows Table Master { ID, Cat1 Datetime, Cat2 datettime } My requirement is to alter themaster table schema i.e to add a column with the name as of the table name i.e Cat3 and will lok lie as foolows Table Master { ID, Cat1 Datetime, Cat2 datettime, Cat3 Datetime } I would like to insert the data to this column. The sample output is as follows Before insertng the data of table ;Cat3' into the Master table Table Master { Id Cat1 Cat2 --------------------------------- 1 D1 D2 2 D2 NULL 3 D3 D4 } And The Cat3 table data is as follows Table Cat3 { ID Update -------------------------- 1 D5 3 D6 4 D7 } The final putput of the master table should be as follows Table Master { Id Cat1 Cat2 Cat3 ------------------------------------------------------ 1 D1 D2 D5 2 D2 NULL NULL 3 D3 D4 D6 4 NULL NULL D7 } Can any one please let me know the query to achieve this Thank you very much for your time and support ~Moahn
View Replies !
View Related
Delete Multiple Rows One At A Time Based On A Condition
Hi, I have the following scenario : CustomerDetail customerid customername status app_no [status = 0 means customer virtually deleted] CustomerArchive archiveno [autoincrement] customerid customername status At the end of the month, I have to physically delete customers. I have written two stored procs: proc1 create proc spoc_startdeletion as declare @app_no int select @app_no = (select app_no from customerdetail where status=0) EXEC spoc_insertcustomerarchive @app_no -- After transferrin, physically delete delete from customerdetail where status=0 proc2 create proc spoc_insertcustomerarchive @app_no int as insert into customerarchive(customerid,customername,status) select customerid,customername,status from customerdetail where app_no = @app_no It works fine if there is only one row with status=0, however the problem is that when there are multiple rows in customerdetail with status=0, it returns 'Subquery returned more than one value' How can i transfer multiple rows one by one from the customerdetail to customerarchive and then delete the rows once they are transferred. Vidkshi
View Replies !
View Related
Showing Data Based On The User Logged In.
Assume I have a heirarchy like the following: - John Smith - James Jones - Robert Allen - Lisa Andrews - Bob Thompson Now, I have a report where whoever is logged in will only see data for themselves and those below them, so John Smith would see everyone including himself, but Lisa Andres would only see herself and Bob Thompson. James Jones would be able to see everyone except John Smith. How do I go about implementing this code, for example in an asp.net page where one of the user's logs on to view the report. Currently, there is a T-SQL function that creates a user heirarchy table, but it is very slow and I am curious if SSRS 2005 has any new capabilities in handling this. Thanks, Saied
View Replies !
View Related
Trying To Create A Proc That Will Insert Values Based On A Condition That Is Another Table
Can someone give me a clue on this. I'm trying to insert values based off of values in another table. I'm comparing wether two id's (non keys in the db) are the same in two fields (that is the where statement. Based on that I'm inserting into the Results table in the PledgeLastYr collumn a 'Y' (thats what I want to do -- to indicate that they have pledged over the last year). Two questions 1. As this is set up right now I'm getting NULL values inserted into the PledgeLastYr collumn. I'm sure this is a stupid syntax problem that i'm overlooking but if someone can give me a hint that would be great. 2. How would I go about writing an If / Else statement in T-SQL so that I can have the Insert statement for both the Yes they have pledged and No they have not pledged all in one stored proc. I'm not to familar with the syntax of writing conditional statements within T-SQL as of yet, and if someone can give me some hints on how to do that it would be greatly appriciated. Thanks in advance, bellow is the code that I have so far: RB Select Results.custID, Results.PledgeLastYr From Results, PledgeInLastYear Where Results.custID = PledgeInLastYear.constIDPledgeInLastYear Insert Into Results(PledgeLastYr) Values ('Y')
View Replies !
View Related
HELP With SQL Query: Select Multiple Values From One Column Based On &&<= Condition.
Hello all. I hope someone can offer me some help. I'm trying to construct a SQL statement that will be run on a Dataset that I have. The trick is that there are many conditions that can apply. I'll describe my situation: I have about 1700 records in a datatable titled "AISC_Shapes_Table" with 49 columns. What I would like to do is allow the user of my VB application to 'create' a custom query (i.e. advanced search). For now, I'll just discuss two columns; The Section Label titled "AISC_MANUAL_LABEL" and the Weight column "W". The data appears in the following manner: (AISC_Shapes_Table) AISC_MANUAL_LABEL W W44x300 300 W42x200 200 (and so on) WT22x150 150 WT21x100 100 (and so on) MT12.5x12.4 12.4 MT12x10 10 (etc.) I have a listbox which users can select MULTIPLE "Manual Labels" or shapes. They then select a property (W for weight, in this case) and a limitation (greater than a value, less than a value, or between two values). From all this, I create a custom Query string or filter to apply to my BindingSource.Filter method. However I have to use the % wildcard to deal with exceptions. If the user only wants W shapes, I use "...LIKE 'W%'" and "...NOT LIKE 'WT%" to be sure to select ONLY W shapes and no WT's. The problems arises, however, when the user wants multiple shapes in general. If I want to select all the "AISC_MANUAL_LABEL" values with W <= 40, I can't do it. An example of a statement I tried to use to select WT% Labels and MT% labels with weight (W)<=100 is: Code SnippetSELECT AISC_MANUAL_LABEL, W FROM AISC_Shape_Table WHERE (W <= 100) AND ((AISC_MANUAL_LABEL LIKE 'MT%') AND (AISC_MANUAL_LABEL LIKE 'WT%')) It returns a NULL value to me, which i know is NOT because no such values exist. So, I further investigated and tried to use a subquery seeing if IN, ANY, or ALL would work, but to no avail. Can anyone offer up any suggestions? I know that if I can get an example of ONE of them to work, then I'll easily be able to apply it to all of my cases. Otherwise, am I just going about this the hard way or is it even possible? Please, ANY suggestions will help. Thank you in advance. Regards, Steve G.
View Replies !
View Related
Different Image Based On Parameter
I am creating a report that will act as statements for our companies, I am slightly stuck at the moment, I have two required parameters one is the company prefix and the other is the customer code. I have a image at the top of the statement that I want to be dynamic i.e. when there is a company code of 1 I want one particular image and when there is a company code of 2 I want another. Is this possible? If so are there any instructions on how one might set this up Thanks
View Replies !
View Related
Safe For Image-Based Deployment
My understanding is that Microsoft SQL Server 2005 (unlike SQL Server 2008) is NOT safe for image-based deployments or at least is not officially supported. Is anyone aware of what tasks need to be performed if an image-based deployment approach is taken? I have Windows and SQL Server installed on HostA, and I want to create an image and install a copy of the image to HostB, HostC, and so on. When the image has been restored to the target machine, I do the following: 1. Run NewSID.exe 2. Change Host Name 3. Change IP Address 4. Change the SQL Server sysservers table via sp_addserver. I noticed that the SQL Server installation program has created sevral Windows groups and SQL Server has several logins, users, and schemas with names associated with the source machine, HostA. My question are: What are these accounts used for? Can or should they be renamed (this shouldn't affect the SIDS, right)? Is there anything else that requires changing? Can this be automated? What "gotchas" should I look for? Or is this simply not "doable"? Any help/guidance is appreciated!
View Replies !
View Related
Image Based Deployment Of SQL Server 2005
Hi All, We have a requriement for mass deployment of SQL server 2005 (Infact, an upgrade from SQL server 2000) with OS upgrade. Just wanted to know the best method in terms of speed and accuracy. Is an image based deplyment possible? I found a couple of links both contradicting each other. http://sqlblog.com/blogs/linchi_shea/archive/2007/12/06/safe-for-image-based-deployment.aspx Says - €œSQL Server is currently not compliant with this criterion€? (image-based deployment) http://www.databasejournal.com/features/mssql/article.php/3499231 Says €“ €œNote that immediately following the installation, SQL Server checks whether the computer name on which it has been installed has changed, and if this is the case, it adjusts its parameters accordingly. This simplifies image-based deployment, where replicas of a disk containing SQL Server installation are copied across multiple systems€? Any responses would be appreciated. Thanks, Ganesh
View Replies !
View Related
COndition Spli - Error Date Condition
Dear friends, I'm having a problem... maybe it's very simple, but with soo many work, right now I can't think well... I need to filter rows in a dataflow... I created a condition spli to that... maybe there is a better solution... And the condition is: Datex != NULL(DT_DATE) (Some DATE != NULL) [Eliminar Datex NULL [17090]] Error: The expression "Datex != NULL(DT_DATE)" on "output "Case 1" (17123)" evaluated to NULL, but the "component "Eliminar Datex NULL" (17090)" requires a Boolean results. Modify the error row disposition on the output to treat this result as False (Ignore Failure) or to redirect this row to the error output (Redirect Row). The expression results must be Boolean for a Conditional Split. A NULL expression result is an error. What is wrong?? Regards, Pedro
View Replies !
View Related
Sending Uploaded Image To Data Access Class When Storing Image In SQL Server 2005
I am using the 3-tiered architecture design (presentation, business laws, and data acess layers). I am stuck on how to send the image the user selects in the upload file control to the BLL and then to the DAL because the DAL does all the inserts into the database. I would like to be able to check the file type in the BLL to make sure the file being uploaded is indeed a picture. Is there a way I can send the location of the file to the BLL, check the filetype, then upload the file and have the DAL insert the image into the database? I have seen examples where people use streams to upload the file directly from their presentation layer, but I would like to keep everything seperated in the three classes if possible. I also wasn't sure what variable type the image would be in the function in the BLL that receive the image from the PL. If there are any examples or tips anyone can give me that would be appreciated.
View Replies !
View Related
How Image Display From SqlServer To Image Control
I have learned lots of informative thing from your forums. I have little problem regarding “Display image from SQL Server on ASP.NET� I have done it and image display on my page from SQL Server. I have cleared you here I have adopt two different methods which are following for displaying picture. 1.Response.BinaryWrite(rd("picture")) 2.image.Save(Response.OutputStream, ImageFormat.Jpeg) but in both above methods I have faced little problem when image display on my page all other information can not display and I also want to display picture on my specific location on the page. My second question is can use any web control like “Image1� to display image from SQL Server where my pictures are stored. Hope you will help me. Thanks and regards Aftab Abbasi
View Replies !
View Related
1st Image Control Shows Wrong Image
In my asp.net application I have a local report with an image control in thedetail row of the table and the Value attribute set as="File://" & Fields!FQPhotoFileName.ValueThe first row in the table always shows the wrong image and it's always thesame wrong image. The problem is there even when I change the sort order orthe criteria for the underlying dataset. For example, I ran a small testthat populated the dataset with 2 rows and 2 images. When I sort by anycolumn (e.g. ID) in ascending ascending order the ID=1 row (the 1st row)shows the wrong image and the ID=2 row shows the correct image. When I rerunthe report sorting in descending order the ID=2 row (which is now the 1strow) shows the wrong image and the ID=1 shows the correct image.Any suggestions?
View Replies !
View Related
Image Located On Web, Url For Image Stored In Database
Hi, I have a website and i am uploading the gif image to the database. i have used varchar(500) as the datatype and i am saving the file in the webserver so the path to it c:intepub....a.gif my upload table has the folliwing feilds UploadId Int Identity, Description, FileName, DiskPath varchar(500), weblocation varchar(500). I have a main sproc for the report where i am doing a inner join with other table to get the path of the gif.. So my question is how can i get a picture to show up on the report. . What kinda datatype the gif file should be stored in the database? If it is stored as a varchar how can i access it and what is best way to reference that particular. any help will appreciated.... Regards Karen
View Replies !
View Related
Inserting Image File Into Image Column In DB
I have inherited a VS 2005 database with a table that has a column of type IMAGE. I need to change the image for one of the rows in the table. I have the new image in a *.PNG file on my C: drive. What is the correct method for inserting this file into the IMAGE column. Many thanks!
View Replies !
View Related
Inserting Image In Image Field
I have a table with two fields 1 int datatype and the other Image data type. I have inserted quite a lot into the tables. And i can display the images in VB. Every thing is fine. Now the problem is I need to update another table on another server over which i cannot connect directly. I thought of inserting the image data field into a notepad directly from the table and from VB open the notepad and insert into the next table. But it doesnt work. Is there any way i can do it. Thanks Sudheesh
View Replies !
View Related
An Easy Way To Reference The Nth Row From A Table Meeting A Condition X, And The Mth Row From The Same Table Meeting Condition Y
Hi I am developing a scientific application (demographic forecasting) and have a situation where I need to update a variety of rows, say the ith, jth and kth row that meets a particular condition, say, x. I also need to adjust rows, say mth and nth that meet condition , say y. My current solution is laborious and has to be coded for each condition and has been set up below (If you select this entire piece of code it will create 2 databases, each with a table initialised to change the 2nd,4th,8th and 16th rows, with the first database ignoring the condition and with the second applying the change only to rows with 'type1=1' as the condition.) This is an adequate solution, but if I want to change the second row meeting a second condition, say 'type1=2', I would need to have another WITH...SELECT...INNER JOIN...UPDATE and I'm sure this would be inefficient. Would there possibly be a way to introduce a rank by type into the table, something like this added column which increments for each type: ID Int1 Type1 Ideal Rank by Type 1 1 1 1 2 1 1 2 3 2 1 3 4 3 1 4 5 5 1 5 6 8 2 1 7 13 1 6 8 21 1 7 9 34 1 8 10 55 2 2 11 89 1 9 12 144 1 10 13 233 1 11 14 377 1 12 15 610 1 13 16 987 2 3 17 1597 1 14 18 2584 1 15 19 4181 1 16 20 6765 1 17 The solution would then be a simple update based on an innerjoin reflecting the condition and rank by type... I hope this posting is clear, albeit long. Thanks in advance Greg PS The code: USE master GO CREATE DATABASE CertainRowsToChange GO USE CertainRowsToChange GO CREATE TABLE InitialisedValues ( InitialisedValuesID int identity(1 ,1) NOT NULL PRIMARY KEY, Int1 int NOT NULL ) GO CREATE PROCEDURE Initialise AS BEGIN INSERT INTO InitialisedValues (Int1 ) SELECT 2 INSERT INTO InitialisedValues (Int1 ) SELECT 4 INSERT INTO InitialisedValues (Int1 ) SELECT 8 INSERT INTO InitialisedValues (Int1 ) SELECT 16 END GO EXEC Initialise /*=======================================================*/ CREATE TABLE AllRows ( AllRowsID int identity(1 ,1) NOT NULL PRIMARY KEY, Int1 int NOT NULL ) GO CREATE TABLE RowsToChange ( RowsToChangeID int identity(1 ,1) NOT NULL PRIMARY KEY, Int1 int NOT NULL ) GO CREATE PROCEDURE InitialiseRowsToChange AS BEGIN INSERT INTO RowsToChange (Int1 ) SELECT 2 INSERT INTO RowsToChange (Int1 ) SELECT 4 INSERT INTO RowsToChange (Int1 ) SELECT 8 INSERT INTO RowsToChange (Int1 ) SELECT 16 END GO EXEC InitialiseRowsToChange GO CREATE PROCEDURE PopulateAllRows AS BEGIN INSERT INTO AllRows (Int1 ) SELECT 1 INSERT INTO AllRows (Int1 ) SELECT 1 INSERT INTO AllRows (Int1 ) SELECT 2 INSERT INTO AllRows (Int1 ) SELECT 3 INSERT INTO AllRows (Int1 ) SELECT 5 INSERT INTO AllRows (Int1 ) SELECT 8 INSERT INTO AllRows (Int1 ) SELECT 13 INSERT INTO AllRows (Int1 ) SELECT 21 INSERT INTO AllRows (Int1 ) SELECT 34 INSERT INTO AllRows (Int1 ) SELECT 55 INSERT INTO AllRows (Int1 ) SELECT 89 INSERT INTO AllRows (Int1 ) SELECT 144 INSERT INTO AllRows (Int1 ) SELECT 233 INSERT INTO AllRows (Int1 ) SELECT 377 INSERT INTO AllRows (Int1 ) SELECT 610 INSERT INTO AllRows (Int1 ) SELECT 987 INSERT INTO AllRows (Int1 ) SELECT 1597 INSERT INTO AllRows (Int1 ) SELECT 2584 INSERT INTO AllRows (Int1 ) SELECT 4181 INSERT INTO AllRows (Int1 ) SELECT 6765 END GO EXEC PopulateAllRows GO SELECT * FROM AllRows GO WITH Temp(OrigID) AS ( SELECT OrigID FROM (SELECT Row_Number() OVER (ORDER BY AllRowsID Asc ) AS RowScore, AllRowsID AS OrigID, Int1 AS OrigValue FROM Allrows) AS FromTable INNER JOIN RowsToChange AS ToTable ON FromTable.RowScore = ToTable.Int1 ) UPDATE AllRows SET Int1=1000 FROM Temp as InTable JOIN Allrows as OutTable ON Intable.OrigID = OutTable.AllRowsID GO SELECT * FROM AllRows GO USE master GO CREATE DATABASE ComplexCertainRowsToChange GO USE ComplexCertainRowsToChange GO CREATE TABLE InitialisedValues ( InitialisedValuesID int identity(1 ,1) NOT NULL PRIMARY KEY, Int1 int NOT NULL ) GO CREATE PROCEDURE Initialise AS BEGIN INSERT INTO InitialisedValues (Int1 ) SELECT 2 INSERT INTO InitialisedValues (Int1 ) SELECT 4 INSERT INTO InitialisedValues (Int1 ) SELECT 8 INSERT INTO InitialisedValues (Int1 ) SELECT 16 END GO EXEC Initialise /*=======================================================*/ CREATE TABLE AllRows ( AllRowsID int identity(1 ,1) NOT NULL PRIMARY KEY, Int1 int NOT NULL, Type1 int NOT NULL ) GO CREATE TABLE RowsToChange ( RowsToChangeID int identity(1 ,1) NOT NULL PRIMARY KEY, Int1 int NOT NULL, Type1 int NOT NULL ) GO CREATE PROCEDURE InitialiseRowsToChange AS BEGIN INSERT INTO RowsToChange (Int1,Type1 ) SELECT 2, 1 INSERT INTO RowsToChange (Int1,Type1 ) SELECT 4, 1 INSERT INTO RowsToChange (Int1,Type1 ) SELECT 8, 1 INSERT INTO RowsToChange (Int1,Type1 ) SELECT 16, 1 END GO EXEC InitialiseRowsToChange GO CREATE PROCEDURE PopulateAllRows AS BEGIN INSERT INTO AllRows (Int1, Type1 ) SELECT 1, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 1, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 2, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 3, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 5, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 8, 2 INSERT INTO AllRows (Int1, Type1 ) SELECT 13, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 21, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 34, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 55, 2 INSERT INTO AllRows (Int1, Type1 ) SELECT 89, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 144, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 233, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 377, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 610, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 987, 2 INSERT INTO AllRows (Int1, Type1 ) SELECT 1597, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 2584, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 4181, 1 INSERT INTO AllRows (Int1, Type1 ) SELECT 6765, 1 END GO EXEC PopulateAllRows GO SELECT * FROM AllRows GO WITH Temp(OrigID) AS ( SELECT OrigID FROM (SELECT Row_Number() OVER (ORDER BY AllRowsID Asc ) AS RowScore, AllRowsID AS OrigID, Int1 AS OrigValue FROM Allrows WHERE Type1=1) AS FromTable INNER JOIN RowsToChange AS ToTable ON FromTable.RowScore = ToTable.Int1 ) UPDATE AllRows SET Int1=1000 FROM Temp as InTable JOIN Allrows as OutTable ON Intable.OrigID = OutTable.AllRowsID GO SELECT * FROM AllRows GO
View Replies !
View Related
How To Return Boolean Through SQL?
I have a stored procedure that returns 1 or 0 as one of the column value. When i execute this stored proc and fill the Data Table in .Net, the data type of this column in Data Table is becomes integer not boolean. What should i return from stored procedure so that when i fill data table the column's datatype will be boolean NOT integer? or is there any way to change the DataType of the column in Data Table?
View Replies !
View Related
Not Able To Store Boolean Value
Hi, I have a FormView with a couple of TextBoxes, a DropDownList and two CheckBoxes. I have connected a SQLDataSource to the FormView with an InsertCommand to store the values entered into the different conrtrols. My problem is that the boolean values from the two CheckBoxes doesn't get stored in the Database (SQL Server Express). The columns in the DB are of type "bit", should I choose a different type? I don't see any errors just a NULL value in the DB. I'm probably missing the obvious taken that I'm really fresh to this, so any help would be appreciated... Code below: <asp:SqlDataSource id="SqlDataSource1" Runat="Server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT TOP 1 * FROM Games" InsertCommand="INSERT INTO Games (GameID, GameDate, Opposition, Result, FirstTeamGame, HomeGame) VALUES (@GameID, @GameDate, @Opposition, @Result, @FirstTeamGame, @HomeGame)" > <InsertParameters> <asp:Parameter Name="GameID" /> <asp:Parameter Name="GameDate" /> <asp:Parameter Name="Opposition" /> <asp:Parameter Name="Result" /> <asp:Parameter Name="FirstTeamGame" Type=Boolean /> <asp:Parameter Name="HomeGame" Type=Boolean /> </InsertParameters> </asp:SqlDataSource> <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" OnItemInserted="FormView1_ItemInserted"> <HeaderTemplate> <table border="1" style="border-collapse:collapse"> <tr style="background-color:#E0E0E0"> <th><asp:Label ID="Label1" Text="Manage" Width="90px" Runat="Server"/></th> <th><asp:Label ID="Label4" Text="ID" Width="60px" Runat="Server"/></th> <th><asp:Label ID="Label2" Text="MatchDate" Width="80px" Runat="Server"/></th> <th><asp:Label ID="Label3" Text="Opponent" Width="118px" Runat="Server"/></th> <th><asp:Label ID="Label5" Text="Result" Width="80px" Runat="Server"/></th> <th><asp:Label ID="Label6" Text="First Team Game" Width="80px" Runat="Server"/></th> <th><asp:Label ID="Label7" Text="Home Game" Width="80px" Runat="Server"/></th> </tr> </table> </HeaderTemplate> <ItemTemplate> <table border="1" style="border-collapse:collapse"> <tr> <td><asp:Button ID="Button1" Text="New" CommandName="New" Runat="Server" Font-Size="8pt" Width="45px" Height="22px" /></td> </tr> </table> </ItemTemplate> <InsertItemTemplate> <table border="1" style="border-collapse:collapse"> <tr> <td> <asp:Button ID="Button2" Text="Insert" CommandName="Insert" Runat="Server" Font-Size="8pt" Width="45px" Height="22px" OnClick="Button2_Click"/> <asp:Button ID="Button3" Text="Cancel" CommandName="Cancel" Runat="Server" Font-Size="8pt" Width="45px" Height="22px"/> </td> <td> <asp:TextBox id="AddGameID" Text='<%# Bind("GameID")%>' Runat="Server" Font-Size="8pt" Width="60" OnDataBinding="CreateNewGame" /> </td> <td><asp:TextBox id="AddGameDate" Text='<%# Bind("GameDate")%>' Runat="Server" Font-Size="8pt" Width="80"/></td> <td><asp:DropDownList id="AddOpposition" Runat="Server" Font-Size="8pt" Width="118px" OnLoad="fillMe"/></td> <td><asp:TextBox id="AddResult" Text='<%# Bind("Result")%>' Runat="Server" Font-Size="8pt" Width="80"/></td> <td><asp:CheckBox id="AddIsFirstTeamGame" Text='<%# Bind("FirstTeamGame")%>' Runat="Server" Font-Size="8pt" Width="80" /></td> <td><asp:CheckBox id="AddIsHomeGame" Text='<%# Bind("HomeGame")%>' Runat="Server" Font-Size="8pt" Width="80"/></td> <td><asp:HiddenField id="Opposition" Value='<%# Bind("Opposition")%>' Runat="Server" /></td> </tr> </table> </InsertItemTemplate> <HeaderStyle Wrap="False" Font-Bold="True" /> <EmptyDataTemplate> <table border="1" style="border-collapse:collapse"> <tr style="background-color:#E0E0E0"> <th><asp:Label ID="Label1" Text="Hantera" Width="90px" Runat="Server" Font-Size="10px" /></th> <th><asp:Label ID="Label4" Text="ID" Width="60px" Runat="Server"/></th> <th><asp:Label ID="Label2" Text="MatchDatum" Width="80px" Runat="Server"/></th> <th><asp:Label ID="Label3" Text="Motståndare" Width="118px" Runat="Server"/></th> <th><asp:Label ID="Label5" Text="Resultat" Width="80px" Runat="Server"/></th> <th><asp:Label ID="Label6" Text="A-lags Match" Width="80px" Runat="Server"/></th> <th><asp:Label ID="Label7" Text="HemmaMatch" Width="80px" Runat="Server"/></th> </tr> </table> </EmptyDataTemplate> </asp:FormView>
View Replies !
View Related
Converting Boolean To Bit
I have a control with checkboxes. The checkbox.checked property returns a boolean value. If I want to insert a record into a table that has a corresponding column of type bit, how do I do it? I triedCType(myChkBox.checked,String), which returns the strings "True" or "False". But, I get the errorThe name 'True' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.I then tried "CAST(" & CType(myChkBox.checked,String) & ",bit)", but got the same error. I can write a function that will return a 1 or a 0 but that seems ludicrous. Surely there must be a more elegant way to use the result of a checkbox in an SQL statement. Thanks Martin
View Replies !
View Related
Setting A Value For A Boolean
Hi,I am trying to get a 0 or 1 depending on the sucess or failure of at-sql statement, and here is what I have:Declare @boolDatabaseExists bitDeclare @chvnNewDatabaseName nvarchar(260)SET @chvnNewDatabaseName = 'NewDatabase'SET@boolDatabaseExists =(SELECT(1)FROMmaster.dbo.sysdatabasesWHEREname = @chvnNewDatabaseName)Print @boolDatabaseExistsWhat it is doing right now is that it prints a 1 for when there is amatch for the @NewDatabaseName in the sysdatabases table. If there isnot a match, then there is no value set for @ boolDatabaseExistsWhat I would like it to do is if there is no match for the@NewDatabaseName in the sysdatabases, I would like to set theboolDatabaseExists to 0I hope I am clear in my explanation.Thank youKR
View Replies !
View Related
Boolean Parameter
Hi, I have a Summary report and a Detail (drillthrough) report. the summary report displays. Summary report Code Snippet Adult | Male | Count ----------------------------- Yes | Yes | 50 Yes | No | 9 No | Yes | 20 No | No | 50 ------------------------------ | 129 When the user clicks on the hightlighted count it links to the Details report displaying each of the records referenced. The detail report uses 2 boolean parameters Adult & Male, this works perfectly for the first 4 lines displayed, however if the user clicks on the total value to display all the records, i'm unable to provide the NULL value. Any ideas?
View Replies !
View Related
Boolean Expressions
I have a unusual problem, well it is unusual becaue i cannot understand it. I am retrieving the following data, Revenue, Sales, Commission, and calculating Commission Rate in the report itself. I got warnings that a textbox that was attempting to calculate the Commission Rate was trying to divide by zero. When I analysed the data, I realised that indeed there were instances when Revenue was 0.00 and therefore when calculating the commission rate, commission/revenue it returned an error. I then thought I'd do the following in the expression field =iif((Fields!RevenueGbp.Value = 0.00), "Zero", (Fields!Commission.ValueGbp/Fields!RevenueGbp.Value)) However this does not work. However if i tried the following Boolean query =iif((Fields!RevenueGbp.Value = 0.00), "Zero", Fields!CommissionGbp.Value) it does work. In fact if I use any other identifier or use two field thats add, subtract or multiplied with each other it will work. The problem only arises is when I decide to divide two fields together. Strangely if the condition is satisfied - [Fields!RevenueGbp.Value = 0.00] - it will still try to work out the division even though it should just return Zero! Anyone help?
View Replies !
View Related
Boolean Variables?
Im wondering how to do a boolean equivilent while creating tables. here is an example: ProgramNoNUMBER(10)NOT NULL, Instead of Number(10) how would I make that a boolean in sql? Im sorry if this is a really easy question, but I looked around online and either was looking for the wrong thing or couldnt find it. Well i guess thats not entirely true, I found it on wikipedia, but just swapping in BOOLEAN doesnt work. Can anyone tell me the syntax? Thanks
View Replies !
View Related
Boolean Selection In An Sql Statement
Hi... I have a problem getting a select statement to return a boolean value from sql server... the aim is to populate a checkbox list with permissions a group of users has. The statement is an outer join as follows: select SS.PermissionName, BB.GroupId,case when BB.GroupId Is Null then cast(0 as bit) else cast(1 as bit)end IsAddedfrom clPermissions SS left join ( select PermissionName, GroupId from clvGroupPermissions where GroupId = (Select groupId from clGroups where GroupName = 'Admin')) BB on SS.PermissionName = BB.PermissionName The returned values are 0 and 1... but .NET does not seem to recognize these values as true and false...Any one had an issue like this before?
View Replies !
View Related
|