Hello everybody, I have following datasource <asp:SqlDataSource ID="sqlIncidentTemplates" runat="server" ConnectionString="<%$ ConnectionStrings:Standard %>" SelectCommand="SELECT [IncidentText] FROM [IncidentTemplates] WHERE [ConstrAreaID] = @ConstrAreaID AND [ConstrDeviceID] = @ConstrDeviceID"> <SelectParameters> <asp:Parameter DefaultValue="" Name="ConstrAreaID" Type="Int32" ConvertEmptyStringToNull="true" /> <asp:Parameter DefaultValue="" Name="ConstrDeviceID" Type="int32" ConvertEmptyStringToNull="true" /> </SelectParameters> As far as I understand default select command should be "SELECT IncidentText FROM IncidentTemplates WHERE ConstrAreaID IS NULL AND ConstrDeviceID IS NULL". Unfortunately this is not the case. I assume that the "[ConstrAreaID] = @ConstrAreaID " is translated into "ConstrAreaID = NULL". Could this be the reason and how can I solve this problem? Thanks in advance
Hi Guys. I am trying to insert the date as the default value into the DatePosted parameter in the sqldatasource object. I have put have the following below but it doesn't work. I have also tried <asp:Parameter Name="DatePosted" Type="DateTime" DefaultValue="<%= Date.Now %>" /> <asp:Parameter Name="DatePosted" Type="DateTime" DefaultValue="<%= now() %>" /> I know the solution is probably simple and I look like an idiot, but excuse me because I am very knew and fragile at this lol... any help would be great :). Mike.
Just thought I'd point it out as something that needs fixing. This is inconsistent with every other MS product using the VS.net IDE framework.
I'd post it on Connect but then I'd wait 2 months to get "won't fix - this does not 'fit' with the current Katmai schedule" i.e. if I'm lucky (based on the new improved 3yr delivery of sql) it might get delivered in 2011. Wow.
Imagine if Xbox or PS3 designers told their customers, "sorry we know that up/down/left/right are in fact right/left/down/up, as you may expect on a game controller, but if you wait 3 years we might fix it"
SELECT sysjobs.name, sysjobservers.last_run_outcome, CONVERT(varchar(8), sysjobservers.last_run_date, 112) AS LastRunDate, CONVERT(varchar(8), sysjobservers.last_run_time, 8) AS LastRunTime, GETDATE() AS CurrentDateTime FROM sysjobs LEFT OUTER JOIN sysjobservers ON sysjobs.job_id = sysjobservers.job_id WHERE (sysjobservers.last_run_outcome = 0) AND (CONVERT(varchar(8), sysjobservers.last_run_date, 112) >= DATEADD(day, - 1, GETDATE()))
I am wanting a similar solution, I need to convert an "int" to a time format, when I use this where ">= DATEADD(minute, - 720, GETDATE())" for the last_run_time I get this error:
Syntax error converting datetime from character string.
I have two tbls joined via a varchar field.. which in tbl I have to use a CASE statement to format it correctly for the JOIN..
All works well.. however, if I add a WHERE clause to the statement, with the WHERE clause affecting only one of the JOINED tbls.. All the NULLS are not shown.
I should get results like:
Postcode Count
tf4 0 tf5 23 tf6 15 tf7 0 etc
Whereas, when I add the where clause, none of the "zeros" are shown, so I get:
tf5 23 tf6 15
Why is this?
Here's the SQL:
SELECT ISNULL(COUNT(CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', '')) WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2) WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3) ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END), 0) AS PCCount, dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country, dbo.UkPostcodes.Master_Account FROM dbo.UkPostcodes LEFT OUTER JOIN dbo.Customers_Trade ON dbo.UkPostcodes.Postcode = CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', '')) WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2) WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3) ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END WHERE (dbo.Customers_Trade.TradeCustomerID IN (SELECT DISTINCT TradeCustomerID FROM dbo.Orders_Trade WHERE (DATEDIFF(d, order_date, GETDATE()) < 60))) AND (dbo.Customers_Trade.is_activated <> 'No') OR (dbo.Customers_Trade.BillingAccountID <> '') AND (dbo.Customers_Trade.BillingAccountID IN (SELECT DISTINCT TradeCustomerID FROM dbo.Orders_Trade WHERE (DATEDIFF(d, order_date, GETDATE()) < 60) AND (is_activated <> 'No'))) GROUP BY dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country, dbo.Customers_Trade.Master_Account, dbo.UkPostcodes.Master_Account
does not show the nulls:
where as:
SELECT ISNULL(COUNT(CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', '')) WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2) WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3) ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END), 0) AS PCCount, dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country, dbo.UkPostcodes.Master_Account FROM dbo.UkPostcodes LEFT OUTER JOIN dbo.Customers_Trade ON dbo.UkPostcodes.Postcode = CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', '')) WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2) WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3) ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END GROUP BY dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country, dbo.Customers_Trade.Master_Account, dbo.UkPostcodes.Master_Account
I am using the Server Explorer in VS2005. I have created an additional field in a small test table with 3 other fields. The new field called foo_key does not show up when I query the table ( it has 7 records ).
I have some tables that I'd like to insert an auto-incrementing integer primary key. But at this point I cant figure out what's wrong. I have toggled the field as primary key on and off.It seems if I create a new table, then I see the primary key field and its autoincrementing as desired.
Could it be that I cannot add such a field if my table already has some records ? ...and to get one in would mean rebuilding a new table and shifting the records....pls advise
SELECT dbo.VIEW1Client.ID, dbo.VIEW1QA.Score, dbo.VIEW1Client.Score AS Score2, CASE WHEN dbo.VIEW1Client.Score = dbo.VIEW1QA.Score THEN 1 ELSE 0 END) AS Calibrate FROM dbo.VIEW1QA CROSS JOIN dbo.VIEW1Client WHERE dbo.VIEW1Client.ID = '1'
View Table 4: (I created a view table using View Table 3 to get the average and it seems not providig the right average, instead I get 0:
SELECT ID, AVG(Calibrate) AS Perc FROM dbo.VIEW3 GROUP BY ID
I modified something on the package, saved it and click on build. When i ran the package, it hit an error. when i saw the object that has an error, it was the one i modified. my changes were not applied. i stopped the runtime. and double click again on that package, it reflected my changes. why during runtime it's showing the old version? what's the proper way of saving the package and building it? What's the different of Build and Rebuild?
SELECT COUNT(dbo.UkPostcodes.Postcode) AS PCCount, dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country FROM dbo.UkPostcodes LEFT OUTER JOIN dbo.Customers_Trade ON dbo.UkPostcodes.Postcode = CASE LEN(REPLACE(dbo.Customers_Trade.PostCode, ' ', '')) WHEN 5 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 2) WHEN 6 THEN LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 3) ELSE LEFT(REPLACE(dbo.Customers_Trade.PostCode, ' ', ''), 4) END
GROUP BY dbo.UkPostcodes.Postcode, dbo.UkPostcodes.Town, dbo.UkPostcodes.County, dbo.UkPostcodes.Area, dbo.UkPostcodes.Country
The query should take all of the UK postcode regions (districts) and then match them up to the postcodes in a customer tbl...
What I'm trying to show is the count for postcode resutls, even the postcodes where there are no customers.
I have two different reports and in these two reports one contains images which is working fine at development site as well as server site but when same report is called from another report using linking facility given in sql report images disappears on server site at development site it is working fine.
how can i show the values of my database in for example texbox.can u give me some simple code on how to connect to my SQldatabase server express? and how i can retrieve the file?thnx
Here is my code. Basically what I am doing is selecting from the database based on the current user. The ReaderResults.Text label is not showing the info pulled from the database, and the ReaderError.Text label is not showing an error. I also tried putting the ReaderResults.Text label inside the loop and that didnt work. Any suggestions? 'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")Dim currentUserID currentUserID = Context.User.Identity.Name.ToString() Label1.Text = currentUserID Dim selectSQL As String selectSQL = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd2 As New SqlCommand(selectSQL, con) Dim reader As SqlDataReaderDim CompanyKey Try con.Open() reader = cmd2.ExecuteReader()Do While reader.Read() CompanyKey = reader("CompanyKey").ToString() Loop reader.Close()Catch err As Exception ReaderError.Text = "Error selecting record." ReaderError.Text &= err.Message ReaderResults.Text = CompanyKey Finally con.Close() End Try
The ReaderResults.Text is not returning a value. I am not sure what is going on because the table and all columns are full, Label1.Text shows the current username of the user loggedon, and no error is showing up in ReaderError.Text. Anyone have any ideas? Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true") 'Job1 InfoDim currentUserID currentUserID = Context.User.Identity.Name.ToString() Label1.Text = currentUserID Dim selectSQL1 As String selectSQL1 = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd1 As New SqlCommand(selectSQL1, con) Dim reader As SqlDataReaderDim CompanyKey 'Job1 Select Try con.Open() reader = cmd1.ExecuteReader()Do While reader.Read() CompanyKey = reader("CompanyKey").ToString() Loop reader.Close()Catch err As Exception ReaderError.Text = "Error selecting record." ReaderError.Text &= err.Message ReaderResults.Text = CompanyKey Finally con.Close() End Try
Hi, We have an internal mail system, but when the user writes something into the textbox (textarea), he often uses enter to get the message over several lines, our problem is that when the message is saved to the database and retrieved, all the breaks are gone and its all on a single line. In the database its stored inside a field called "message nvarchar(MAX)". How can i preserve the linebreaks? example, user writes: Hello,Nice day,to go fishing. output, after it has been saved and retrieved: Hello, Nice day, to go fishing.
Any idea why I cannot see (in Enterprise Manager) all the coulmns of a selected table? All I get is * all columns - not each one, meaning I cannot select individual columns in my new view. Could it be the version? I am running SQL 7.0 SP1
I used Query Analyser to De-tach a SQL 7 database and that worked fine. The database became 'invisible' in Enterprise Manager and the entry was removed from the sysdatabases in Master. The mdf and ldf file remain in the file system. However, when I ran the sp to Attach the database QA said successful but it does not show in Enterprise Manager or in sysdatabases in Master. I'm going to run through the procedure again and if problems I'll check the logs but has anyone else had difficulty with this. Also with attaching the db to a SQL2000 install I believe the logins on the SQL7 install are not brought over. In my case, the client is using trusted logins with their database application so their is probably not a lot to manually recreate on the SQL 2000 install but doees anyone have nay sample code/script that can give me an idea of what is required in the area of getting logins out of the Master of SQL7 and into SQL2000.
I've added a new drive to a clustered instance of sql 2000. Go to the node the instance is active on, the drive shows up. But...try to add a backup device that lives on the new drive (which was, after all, the whole point of the exercise) and SQL Server is blind to that drive. I have vague recollections of it recognizing the clustered drives when i set up all this a couple years ago. Could it be that it recognizes all the drives it'll ever recognize at the moment of installation? Anybody know?
I want to have all the ethnicities from the Ethnicgroup table to be displayed in a particular area which is in where clause as aggcourseid
The problem is that even when I have a left join on the EthnicGroup table it will not return all the ethnicities but will only return those who were existing in that particular aggcourseid.
i.e. If there is no African student in E2, it will not show up in the result whereas I want to display all the ethnicities and if there is no record for aggcourseid, it should show up as 0/NULL for that ethnicity.
I have tried all sorts of joins but the problem is whenever I put in the aggcourseid in where clause, it wont bring all the records
--Year 05/06 insert into #temp_et select CAST(LEFT(pv.pg_expendyrid,2) AS int)[Year], eg.pg_ethnicgroupname[Ethinicity], sum([pvstart]) [Starts],
(case when sum(pvstart) = 0 THEN 0 Else convert(decimal(6,3),(sum(pvach)*1.00)/(sum(pvstart)*1.00)*100)end)[Success], (case when sum(pvstart) = 0 THEN 0 Else convert(decimal(6,3),(sum(pvcomp)*1.00)/(sum(pvstart)*1.00)*100)end)[Retention], (case when sum(pvstart) = 0 THEN 0 Else convert(decimal(6,3),(sum(pvach)*1.00)/(sum(pvcomp)*1.00)*100)end)[Achievement] --into temp_et from [FECAS].Proachieve.dbo.pv_midpoint pv left join [FECAS].Proachieve.dbo.GN_AggCourseStructure gn on pv.pg_aggcourseid = gn.pg_aggcourseid left join [FECAS].Proachieve.dbo.PG_ethnicGroup eg on pv.pg_ethnicgroupid = eg.pg_ethnicgroupid
where pv_midpointid = @mpid and pg_expendyrid = '05/06'
and pv.pg_aggcourseid LIKE 'E2%'
group by eg.pg_ethnicgroupname, pv.pg_expendyrid order by eg.pg_ethnicgroupname
I moved a database file (.mdf) from the Microsoft SQL Server data directory to another location, and moved it back into the original location. After which the database staus changed to suspect.
We have nightly job running to reorg all in one of our prod database. But the index on one of the table fragmenting quickly by the morning showing 90% fragmentation.
i have 2 columns like Col1====col2 username=======saif====mr@hotmai.com email=======saif@hotmail.com name======saifullah I want to get these records from sql like username email name saif saif@hotmail.com saifullah ________________________________- how can I achive this
I've been unable to determine why several published instances of my SQL Servers are not showing in AD. I searched under the Computer container in the domain in which the SQL Server was installed and did not see any SQL Server folder. I have used both the GUI and T-SQL to publish various instances, and it appeared to have worked since from the GUI the "Publish" option no longer worked and I recieved no error from Query Analyzer after issuing the command. The version is SQL Server 2000 8.0 running SP3a.
I also ran a VBScript to query the directory for published instances of SQL server, but did not get any results returned in the recordset. Any ideas?
Hi @all, I just installed SQLServer 2005 Developer edition on a WinXPPro Virtual PC. Installation went fine, however i see no items in my Start menu. There's only SQL Server 2005 Configuration tool. Where's all other stuff gone?
Everything should be on my computer, but I can't get to it. I.e. if i go check the installation (Add&remove progs/Server 2005 and click Change) there's everything there, Analysis server, Business intelligence, etc. But no items in my Start menu.
Also, if i re-enter either of the 2 installtion CDs, there's only two things in the INSTALL part: Server components and Run SQL Native Client Install... Where's "install server" link?
Please bear with me. Newbies are hard Thank you very much for any advice. Jan
I am currrently working on a ASP.Net 2.0 project using Sql Server 2000 with SP4. Whenever I run any query the connected database keeps showing as 'Suspect' and I can't access it from Enterprise Manager/ Query Analyzer. But my ASP.NET pages work fine. I can access my records as well as update them through my ASP pages. Please help me out.... Here is the code which I use in my ASP.Net page
****************************************************** Dim selectsql As String selectsql = "select au_fname FROM Authors" Dim con As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=""C:Program FilesMicrosoft SQL ServerMSSQLDatapubs.mdf"";Integrated Security=True;Connect Timeout=30;User Instance=True") Dim cmd As New SqlCommand(selectsql, con) Dim ass As SqlDataReader
Try con.Open() ass = cmd.ExecuteReader Do While ass.Read Dim newitem As New ListItem() newitem.Text = ass("au_fname") 'newitem.Value = ass("zip") ddl.Items.Add(newitem) Loop
ass.Close()
Catch ex As Exception lblmsg.Text = "error has occured " lblmsg.Text &= ex.Message
Finally If (Not con Is Nothing) Then con.Close() End If End Try *********************************************
This is showing the details I am looking for. Is there a way to show the totals for the clients for 418 and totals for 417?
SELECT NAME.Nickname1, NAME_1.Nickname1 AS Expr1, SLPTRANS.ActyExpID, SLPTRANS.TimeSpent / 3600 AS Hours FROM CUSTOMC INNER JOIN NAME AS NAME_1 ON CUSTOMC.RecordIDQ = NAME_1.RecordID INNER JOIN NAME ON CUSTOMC.ControllerQ = NAME.RecordID INNER JOIN SLPTRANS ON CUSTOMC.RecordIDQ = SLPTRANS.ClientID WHERE (NAME.NameType = 0) AND (CUSTOMC.Service_Cont = 'YES') AND (SLPTRANS.ActyExpID = '417') OR (SLPTRANS.ActyExpID = '418') AND (SLPTRANS.StartDate BETWEEN @IncludeStartDate AND @IncludeEndDate)
I am new to SQL server and I am looking for the best practiceregarding the following:The GUI for the database I am creating has a number of questions like:A. Where are you currently living?1) In my own home2) In the home of a family member3) In a shelter4) On the streetHowever, for speed of data entry, the GUI (it's a web front-end,ASP/VBScript) accepts the number only. Futhermore the database onlystores the number entered.So for example for the above question, when the user is doing the dataentry, they would just enter a 1, 2, 3, or 4.However, when viewing the data, the end user wants to see the textthat corresponds to the number. So for example, if the user entered"3" for the above question, when they are viewing the data in the GUI(not to make edits, just viewing), they want to see "(3) In ashelter".My question is how best to display these friendly values?Should I do all the conversions in a stored procedure? If so, whatwould be the best way to do that? I tried something like this:SELECT Current_living =CASE Current_livingWHEN 1 THEN '(1) In my own home with my partner'WHEN 2 THEN '(2) In the home of a family member'ELSE NULLENDFROM tbl_DemographicInfo WHERE ClientID = @ClientIDbut I can't figure out how to do this for multiple fields.ALSO, I'm not sure if burying this stuff in a stored proc is the wayto go, because if the client wants a slight change to the friendlyname I have to get into the SP and change it. Seems like there mustbe a better way.I can also do this in the ASP code, but that also doesn't seem likethe best practice.I can have a lookup table, but again, where do I do the conversion?In an SP? With a view?Again, I'm looking for the best practice here. I know some ways Icould do it (like in the ASP), but I want to do it efficiently andcorrectly.Any help/comments are greatly appreciated.thanks in advance,Jon LaRosajlarosa at alumni dot brown dot edu