Hi. Not sure which section this request needs to be put in, but i'm relatively new to SQL.
I have 1 table which contains an user_id (autonumber), user_name, and user_profile.
I have 2 other tables:
config_version (cv) and config (c)
These two tables both access the user table (us) to view the user_id (which is required).
I want to be able to view the user_names for both "cv" and "c" on a seperate page. Using the code below, i'm lost. I created what i wanted in MS Access with the use of a 2nd table (this might be easier to understand than my rant above). However, I don't want a 2nd table.
Can someone provide me with a function, or the "answer" to my problem?
Highlighted Blue - just there to fill in the front page with data (not wanted)
Highlighted Green - doesn't work, but was my first attempt
Code:
public function ShowQuotes
Dim objConn
Dim objADORS
Dim strSQL
Dim row
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = strConn
objConn.Open
Set objADORS = CreateObject("ADODB.RecordSet")
strSQL = "Select top 50 "
strSQL = strSQL & " cv.config_version_id as cvid, cv.configuration_id as cid, cv.version_number as cnum"
strSQL = strSQL & ", cv.status as cstat, cv.total_price as cprice, cv.modification_date as cmod, cv.version_description as cvrem"
strSQL = strSQL & ", c.remarks as qrem"
strSQL = strSQL & ", p.prod_description as pdesc, p.version as pvers, p.status as pstat"
strSQL = strSQL & ", cust.customer_name as custname"
strSQL = strSQL & ", us.user_nt_login as modname"
strSQL = strSQL & ", us.user_name as usname"
' strSQL = strSQL & ", cv.user_id as modname"
strSQL = strSQL & " from tbl_config_version as cv, tbl_configuration as c, tbl_product as p, tbl_user as us, tbl_customer as cust"
strSQL = strSQL & strWhere 'SETS RESULTS TO BE UNIQUE
strSQL = strSQL & " and us.user_id = c.user_id"
strSQL = strSQL & " and cv.configuration_id = c.configuration_id"
strSQL = strSQL & " and c.product_id = p.product_id"
strSQL = strSQL & " and c.customer_id = cust.customer_id"
strSQL = strSQL & strOrderBy & ";"
Dont laugh; How do I create a simple sqlcommand in C# that shows data. I have the code for VB but I a missing something in the converstion. I know SQL but I dont get the simple steps of displaying data. I have got all of the Visual Basic stuff down I just need help with doing it by hand in C#. or point my to a URL so that I can get the code. Thanks
Hi all, this is a very basic question of diplaying a data. on my aspx page I have datasource that will return only ONE record. <asp:SqlDataSource ID="sdsCategoryName" runat="server" ConnectionString="<%$ ConnectionStrings:KaruselaConnectionString %>" SelectCommand="SELECT Title FROM tbh_Categories WHERE CategoryID=@categoryID "> <SelectParameters> <asp:QueryStringParameter DefaultValue="-1" Name="CategoryID" QueryStringField="id" Type="int32"/> </SelectParameters> </asp:SqlDataSource> on the server side I would like to manipulate the title of the page according to the data returned from the query: and on the behind code if (!this.IsPostBack && !string.IsNullOrEmpty(this.Request.QueryString["ID"])) { DataView dv2 = (DataView)sdsCategoryName.Select(arg); this.Title = string.Format(this.Title, dv2.Table.Columns[0].ToString()); dv2.Dispose(); } of course it doesn't work. my question is this. do we really have to put the query datasource on the client side?and secondly, how can I view the recorsd I recieves from the query?Thanks for the help.
Hi I have used the create user wizard to create a registration page my table stores the user details and user id. I am also using the login wizard to create a log in page . I now want to display the details of the currently logged in user usind details view and allow them to view and edit their details. where and how do i create the session varible anh how do I wtire the sql select statement say select first name from table1 where (the userid I stored earlier in a table when the user registered ) = (this should be the currently logged in user'id). I am a novice so I would appreciate code snippets My code in asp page for the details looks like this asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" Height="50px" Width="125px"> <EditRowStyle BackColor="#CCFF99" /> <AlternatingRowStyle BackColor="#FFCCFF" /> </asp:DetailsView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>" SelectCommand="SELECT [FirstName], [LastName], [City], [Listing] FROM [UserDetails] WHERE ([UserId] = @UserId)"> </asp:SqlDataSource>
novice This shows no data when I test it. I have tried the folling in the .vb page no luck. Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.DataBound Dim UserId As Integer = Me.DetailsView1.DataItem("userID")Session("_UserID") = UserId End Sub
In sql server, multiple instances of data default to a row display or vertical. I need a set of data in sql2005 to view horizontally so I can us it in a crystal report. Here is my issue. gift.HonorKey, gift.HonorName, gift.HonorId 1211 Smith 1222 1244 Owens 4155
I need for the data to read like this: HonorKey1, HonorKey2, HonorName1, HonorName2, HonorId1, Honorid2 1211 1244 Smith Owens 1222 4155
the table name is gift_view
I would like to be able to create a view in sql analyzer, then save as an SQL View My direct email is jackfam@comcast.net
Im trying to display data from a database based on an input value. The value in the Label12.Text which is("hotmail") is the input value thats stored in the database, this value is been searched for in the strSQL. Dim strSQL As String = "SELECT Name FROM Jobseeker WHERE Email='" & Label12.Text & "' " strSQL = Label5.Text
the code builds successfully, but Label5.Text appears blank.
Hello, Im new to SQL. Im currently having a table called Daily with 5 columns. TesterNames,Activity,Hours_given,Hours_used and Delta. I have grabbed the data for the first three colums from another table called Tester. For Hours_used I supposed to get the data from another server after i get the access but mean time i just put my own data so that i can check the value of Delta. Data for Delta column should be as below. Delta = Hours_given - Hours_used So How do I do the codings for this expression and display it in the same table. Output I need as below: TesterNames Activity Hours_given Hours_used Delta abc A 5 6 -1 def B 7 6 1
I have used INSERT INTO Daily ( TesterNames,Activity,Hours_given) SELECT ( Tester_ID,Weekday_Day,EntityWDD) FROM Tester and the first 3 columns are filled with the data needed. But when I use INSERT INTO DAILY(Delta) SELECT Delta = Hours_given - Hours_used FROM DAILY The output was like below TesterNames Activity Hours_given Hours_used Delta abc A 5 6 def B 7 6 Null Null Null Null -1 Null Null Null Null 1 Help me . thank you.
Everything works great on my development box. I am using GoDaddy for production (ASP.Net v2, SQL 2000). I am not receiving any errors, so I am stumped; no data from the database is displaying on the GoDaddy pages. I updated the connection string in web.config to this:
But I am unsure if this is the issue?? Any insights? This is the page I am working on: www.sugarandspicebakery.com/demo/bakery/default.aspx. So, the page displays fine, but it should be showing data from the database. This particular page uses a DataList with ItemTemplate. There is definitely data in the database, and I have even ran the same exact query from the code using the Query Analayzer on GoDaddt and it returned results I know there isn't much info to go by, but I am hoping someone has some insight since I have been trying to figure this out for days now! Thank youJennifer
I defined a stored procedure with a cursor inside for updating data. When I call it from an MSAccess client, it fails. When I execute it directly in a ISQL/w windows, it doesn`t fail but it displays me the data (wich is the reason for failing from MSAccess). Do somebody know if I could do it without displaying data in the screen ??
Hey all, hopefully this question is in the right spot. I'm writing a .NET app talking to a MS SQL 2000 DB. I have two date range input boxes, and I want to display the data (probably in a dataGrid) from those 2 certain dates. How do I go about this with my SQL server??
My DB table has a date field that I would use to search for the data between those two user specified dates. Any tips, examples, etc. would be greatly appreciated!!!
I have a procedure that allows a user to enter two dates to run a query. I would like to display those dates on the generated report underneath the title. "5-01-07 to 5-31-07" How would I do this?
I have a table where I need to display groupings of information. If there isn't any data for a given group, I still need to include that group and say "no applicable data" or somesuch underneath it. Any way of doing this?
Hi all. I want to display the data from this table (data provided below in my report) PlanId, ParticipantId, FundId, FundNames, Loans,PortfolioId, Act1, TotAct1, Act2, Totact2 etc.. Until act20, totAct20
18752 1041 Columbia Funds Trust VI: Columbia Small Cap Value Fund I; Class A Shares NULL NULL NULL BB 425.32 CT 0.00 DV 0.00 GL 17.40 TF 0.00 WD 0.00 OT 0.00 EB 442.72 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
18752 6204 Columbia Funds Series Trust: Columbia Small Cap Index Fund; Class A Shares NULL NULL NULL BB 120.09 CT 0.00 DV 4.04 GL 2.10 TF 0.00 WD 0.00 OT 0.00 EB 126.23 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
18752 10302 Columbia Funds Series Trust: Columbia Marsico 21st Century Fund; Class A Shares NULL NULL NULL BB 119.59 CT 0.00 DV 1.69 GL 10.41 TF 0.00 WD 0.00 OT 0.00 EB 131.69 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
18752 11010 Columbia Acorn Trust: Columbia Acorn International Select; Class A Shares NULL NULL NULL BB 125.06 CT 0.00 DV 0.33 GL 8.83 TF 0.00 WD 0.00 OT 0.00 EB 134.22 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
18752 11024 Columbia Acorn Trust: Columbia Acorn International; Class A Shares NULL NULL NULL BB 126.85 CT 0.00 DV 0.77 GL 10.07 TF 0.00 WD 0.00 OT 0.00 EB 137.69 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
I will have around 10 -15 records depending on how many funds the user has... and i want my report to look like this
InvestmentName Act1 (BB) Act2(CT) Act3(DV) Act4(TF) ..Act20 FundNames TotAct1 TotAct2 TotAct3 TotAct4 .. Totact5 so the data will be displayed for each fund in different rows..
I am storing the value acroynms and what they stand for a different table and i know there are 20 acroynms and i need to the description of that acronymn to show in the heading... How can i do it... I am trying to right a sproc for it... Any help will be greatly appreciated... if you need more information.. pls feel free to ask
I have a table with:Name, Qtr, AmountTom, 1, 100Bob, 1, 123Tom, 2, 234Bob, 2, 456Steve, 1, 565Steve, 2, 898I want the query to return:Name, Qtr 1 Amount, Qtr 2 AmountBob 123 456Steve 565 898Tom 100 234I can't seem to figure this out! Any help would be appreciated!!Sheila
Hello,I'm having problems saving and then displaying binary data in sql server.I have a form that takes a file specified by the user and inserts this into sql server:protected void btnUploadFile_Click(object sender, EventArgs e) { if (theFile.PostedFile != null) { if (theFile.PostedFile.ContentLength > 0) { byte[] docBuffer = new byte[theFile.PostedFile.ContentLength]; Response.Write(theFile.PostedFile.ContentType.ToString()); if (docBuffer.Length > 0) { // save to db DbAccess dbAccess = new DbAccess(); // my helper function for all db access etc try { dbAccess.BuildCommand("Incentives_SaveDocument"); dbAccess.Parameters.Add("@docImage", SqlDbType.Image).Value = docBuffer; dbAccess.ExecuteNonQuery(); } catch (Exception ex) { Response.Write(ex.ToString()); } } } } }Stored proc:ALTER PROCEDURE Incentives_SaveDocument @docImage imageASSET NOCOUNT ONINSERT INTO Table1 (theData) VALUES (@docImage) RETURNThis appears to work fine. I store the binary data in a image column and if I query the db it shows the row as <Binary>.The problem I have is with retrieving the data and saving it to a file. The file saves OK but when I open it is contains lots of "squares" that I suppose are the binary - it doesn't show the text.The code for retrieving/displaying the doc is:protected void btnView_Click(object sender, EventArgs e) { DbAccess dbAccess = new DbAccess(); byte[] byteArray = null; try { dbAccess.BuildCommand("Incentives_RetrieveDocument"); dbAccess.Parameters.Add("@id", SqlDbType.Int).Value = 6; // id for the doc to return SqlDataReader reader1 = dbAccess.ReturnDataReader(); while (reader1.Read()) { if (reader1.HasRows) { byteArray = (byte[])reader1["theData"]; } } reader1.Close(); FileStream fs = new FileStream("file1", FileMode.CreateNew, FileAccess.Write); fs.Write(byteArray, 0, byteArray.Length); fs.Flush(); fs.Close(); FileInfo fileInfo = new FileInfo("file1"); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name); HttpContext.Current.Response.AddHeader("Content-Length", fileInfo.Length.ToString()); HttpContext.Current.Response.ContentType = "application/msword"; HttpContext.Current.Response.WriteFile(fileInfo.FullName); HttpContext.Current.Response.End(); } catch (Exception ex) { Response.Write(ex.ToString()); } finally { dbAccess.CloseDbConnection(); }The stored proc:ALTER PROCEDURE Incentives_RetrieveDocument @id intASSET NOCOUNT ONSELECT * FROM Table1 WHERE id = @id RETURNI would be grateful for any advice on this - its the first time I've worked with BLOB data.ThanksSi
Ok, I'm fairly new to .NET and even newer to the whole database concept. But, don't run away yet, I'm no idiot and I shouldn't have too hard of a time understanding your responses if you're kind of enough to give them. That being said, here's my dilemma:I'm trying to make a database of all the movies I own, the actors in them and the genre (s) they belong to. I have a set of tables that are in the 2NF (I think). I have a movies table, an actors table, a genres table, and two tables called movies_actors and movies_genres with primary-foreign key relationships to pull it all together (e.g. movie_id 1 has two entries in movies_genres, one for Action and one for Drama). My problem arises that when execute my monster query to pull ALL the data on one movie, I get a row returned for every combination of Genres and Actors in a movie. Example:movie_id movie_title comments actor_first actor_last genre_name1 Casino blah blah Robert DeNiro Action1 Casino blah blah Robert DeNiro Drama1 Casino blah blah Joe Pesci Action1 Casino blah blah Joe Pesci Drama And here's the query that produced that:1 SELECT movies.movie_title, movies.comments, actors.actor_first, 2 actors.actor_last, genres.genre_name 3 FROM movies INNER JOIN movies_actors ON movies.movie_id = movies_actors.movie_id 4 INNER JOIN actors ON movies_actors.actor_id = actors.actor_id 5 INNER JOIN movies_genres ON movies_genres.movie_id = movies.movie_id 6 INNER JOIN genres ON movies_genres.genre_id = genres.genre_id So, I want to put all the actors for one movie into the same cell in the datagrid (same with the genres) and still keep it sortable by actor or genre. Is this possible with the .NET 2.0 datagrid? Do I have some fundamental misunderstanding of how my tables should be structured? Am I just really far off and acting like a n00b?
I am working on an ASP.NET site to display information about authors and books. I'm working on the Author page right now and I'm having trouble getting it to display the data I want. I'm trying to do everything with declarative controls and as little code-behind as possible. I have a datasource on the main page that selects the Author data and provides this to a FormView. Inside the FormView is another datasource that takes the AuthorID as a parameter and selects the list of books, which is provided to a DataList. Inside the DataList I display some limited Book information. I also want to display some child items of the Book (grandchildren of the author), for example other authors who contributed to that book, or alternative titles. I have tried using datasources in each DataList row with a parameter set to the BookID, and it works just great, but the response time is just not acceptable. Each datasource of possible several dozen is making its own call to the database and it's just too slow. If I use code I can grab all the data in one operation and use relations in the DataBinding event (I believe) to select the data I want, but this is a bit cumbersome and I expect will cause trouble if I want to eventually use an ObjectDataSource. Incidentally, on a display-only page I use the XMLDataSource and it works great, but I need read-write access on the Edit page. Is there a good way to do what I'm trying to do?
My report links to a SQL server and is not showing the latest information. If I open it now and look at the report, close it and open it again ina few hours it will show the same report as I looked at originally. When I push the reports refresh button then the data refreshes and shows all the information.
The execution for the report is already set to: Do not cache temporary copies of this report
Why does this happen? I have about 40 reports that work perfectly but this one is giving me problems, any one got any ideas for me? Please help.
Well the first half of it I am able to retrieve meaning the 'Demand' part by pivoting it from the table request and the next part i.e. 'Supply' is also obtained in the similar fashion.
Tbl_User may contain more skill categories than those mentioned in Tbl_Request. So the output should reflect only those categories that are existing in tbl_Request. How can we combine the both? I have taken both the outputs in two temp tables. Now I would like to know if I can combine them and show it as one output or if there is any other better way of doing it.
I am using a stored procedure which is called for my web application so I didn't go for views. Can someone tell me how to do it.
I like to get data from a signle table and arranged in hierarchical(hierarchy) order. What will be my sql script to be able to get the desired result shown below? Please include some explanation as too what script is doing..
Table Structure and Sample Data
Id ParentId Name Code DisplayOrder 1 null Group 1 G00001 1 2 null Group 2 G00002 2 3 1 Sub-Group 1 SG0001 1 4 2 Sub-Group 2 SG0002 1 5 3 Sub-Sub-Group 1 SSG001 1 6 null Group 3 G00003 3 7 3 Sub-Sub-Group 2 SSG002 2
Desired Result Id ParentId Level Name ExtendedName DisplayOrder 1 null 1 Group 1 Group 1 1 3 1 2 Sub-Group 1 Group 1 -> Sub-Group 1 1 5 3 3 Sub-Sub-Group 1 Group 1 -> Sub-Group 1 -> Sub-Sub-Group 1 1 7 3 3 Sub-Sub-Group 2 Group 1 -> Sub-Group 1 -> Sub-Sub-Group 2 2 4 2 2 Sub-Group 2 Group 1 -> Sub-Group 2 1 2 null 1 Group 2 Group 2 2 6 null 1 Group 3 Group 3 3
My report links to a SQL server and is not showing the latest information. If I open it now and look at the report, close it and open it again ina few hours it will show the same report as I looked at originally. When I push the reports refresh button then the data refreshes and shows all the information.
Why does this happen? I have about 40 reports that work perfectly but this one is giving me problems, any one got any ideas for me? Please help.
Hi, In my report, I have a table that displays all the data from query. I need to take the value of the 3rd row,2nd column of the table and display in a text box. I tried to do like:
=ReportItems("TextBox2").Value., where TextBox2 is the 3rd row,2nd column of the table. This returns just the first row value of the seleted data. But, I need the 3rd row value.
This probably has been addressed before but I was unable to get the search to work properly on this site. I am needing a script/way of deleting all rows from a DB with the exception of one record left for each row that has duplicate column data. Example : Row 1 Field1 = 12345 Field2 =xxxxx Field 3=yyyyy Field4=zzzzz etc. Row 2 Field1 = 12345 Field2 =zzzzzz Field 3=xxxxxx Field4=yyyyyy etc. Row3 Field1 = 12345 Field2 =20202 Field 3=11111 Field4=zzzzz etc. Row 4 Field1 = 54321 Field2 =xxxxx Field 3=yyyyy Field4=zzzzz etc. Etc. Etc.
I want to be able to find the duplicates for Field1 and then delete all but 1 of those rows.( I don't care which one I keep just so only one is left.) The data in the other fields may or may not be unique.
I know how to find the duplicates it's just the deleting part I am having problems with. Any help would be much appreciated. Thanks,
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NWHCConnectionString %>" SelectCommand="SELECT * FROM [AI_news]" OnSelecting="SqlDataSource1_Selecting"> </asp:SqlDataSource> This is my code, I have followed the wizard perfectly the way its supposed ot be, well not 100% perfectly. This is how its supposed to be. When using a XXXX.MDF file I could use the wizard and it works fine. I do not know why my above code won't work. I am connected to the database and can view code manually. but not on a aspx page. i am using master page, now trying to add this into default.aspx Any help will be appreciated. I am currently losing some hair.
i have such a error in my sql server db i examined arabic_ci_as and SQL_Latin1_General_CP1256_CI_AS but in my web pages that uses utf-8 codepage that retrieves data using ado and asp scripting the ouput or inserted that dispalyed in both of query analyzer and Enterprise manager replaces or display '?????' for characters . i am using nchar and nvarchar and ntext
I want to set the default value of the parameter based on the query result, when the current_status parameter is set as "opened" I want a certain date value to be displayed in the next parameter (start date), if it is set as closed I want a different date value to be displayed in the next parameter (start date), so I created the dataset with the query given below and assigned the default value to the query fields start and end date, however my Report parameters are not changing as expected.
dataset query:
IF @current_status = 'Opened' SELECT DISTINCT cast(DATEADD(yy, DATEDIFF(yy, 0, getdate()), 0) AS date) AS Start_Date1, cast(MAX(estcompletion_date) AS DATE) AS End_date FROM <Table Name> ELSE IF @current_status = 'Closed' SELECT distinct cast(DATEADD(yy, DATEDIFF(yy, 0, getdate()), 0) AS date) AS Start_Date1, cast(getdate() AS DATE) AS End_date FROM <Table Name>
I have written a sql query which gives me data in report in below format..Need to display data in following format
Client data row has nothing to do with address data row Client are just a distinct list of Client and do not line up with any address . In other words, the order and vertical alignment have nothing to do with the address on the right.
i have a search page having four text boxes like name,accountnumber,ssn..etc we have to search the database by these values. but even if we give value in one text box keeping the others null the stored procedure have to serach and get the values. and we display it using gridview control.
here is the stored procedure i wrote.but its not working.its not giving any erros...but its not showing any values.
AS BEGIN if(@name!=null AND @ssn!=null AND @accountnumber!=null) select * from Userinfo where name=@name AND ssn=@ssn AND accountnumber=@accountnumber else if(@name=null AND @ssn!=null AND @accountnumber!=null) select * from Userinfo where ssn=@ssn AND accountnumber=@accountnumber else if(@name=null AND @ssn=null AND @accountnumber!=null) select * from Userinfo where accountnumber=@accountnumber else if(@name!=null AND @ssn=null AND @accountnumber!=null) select * from Userinfo where accountnumber=@accountnumber AND name=@name else if(@name!=null AND @ssn=null AND @accountnumber=null) select * from Userinfo where name=@name else if(@name!=null AND @ssn!=null AND @accountnumber=null) select * from Userinfo where name=@name AND ssn=@ssn else if(@name=null AND @ssn!=null AND @accountnumber=null) select * from Userinfo where ssn=@ssn
end
table name is userinfo
please help me with this. its very urgent. thanx for your help in advance.