Display Data Using Mxdatagrid Or Datagrid In Webmatrix
Feb 24, 2004
what i'm trying to do is simply display the contents of the sqldata to verify that it works. and it doesn't. i have created a simple database named 'test' and table 'list' with fields: 'name' and 'id'. i have made 3 records as follows:
NAME ID
name1 1
name2 2
name3 3
what i did is connect to the database, click and drag it over to the canvas and codes were generated. if i run it, by default it should show all the contents of the table, correct? well, it isn't. i've tried it using a datagrid and it still doesn't work.
is there an access problem with the database? or, what settings to have to make/change in my sql server? by the way, i have MSDE.
Hi, Im trying to pull data from 2 fields in the same table into a SqlDataSource that feeds into a GridView, and display them as 1 field in GridView? I have a database table that has entries of users and their friends. so this tblFriendUser has a column called UserName and another column called FriendUserName. I am trying to get a list of friends for that particular user. Note that if User1 initiated the friend request, he will be listed as UserName and his friend as FriendUserName, but if his friend initiated the friend request, it will be vice versa: him being the FriendUserName and his friend the UserName. So I want the following 2 queries run and merged into one query in order to return 2 columns only: UserFriendID & UserName, is that possible? Is my design bad? Any suggestions/advice would help! Thanks a lot!
SELECT UserFriendID, UserName FROM tblUserFriends WHERE (UserName = @UserName);
SELECT UserFriendID, FriendUserName AS UserName FROM tblUserFriends WHERE (FriendUserName= @UserName);
I have nine type of buttons, EnrollAmtBTM PlacAmtBTM and so on, I also have a SQL setver view V_Payment_Amount_List from here i need to display the data on the button this is the select value to display when i choose the agency list and the amount corresponding to that agency_ID is displayed here the agency_ID is fetched from the SQL CONDITION THIS IS WHERE I GET FETCH AGENCY DATA WHEN SELECTED i.e SQL CONDITIONprotected void CollectAgencyInformation() { WebLibraryClass ConnectionFinanceDB;ConnectionFinanceDB = new WebLibraryClass(); string SQLCONDITION = "";string RUN_SQLCONDITION = ""; SessionValues ValueSelected = null;int CollectionCount = 0;if (Session[Session_UserSPersonalData] == null) {ValueSelected = new SessionValues(); Session.Add(Session_UserSPersonalData, ValueSelected); } else { ValueSelected = (SessionValues)(Session[Session_UserSPersonalData]); }ProcPaymBTM.Visible = false;PaymenLstBTN.Visible = false; Dataviewlisting.ActiveViewIndex = 0;TreeNode SelectedNode = new TreeNode(); SelectedNode = AgencyTree.SelectedNode; SelectedAgency = SelectedNode.Value.ToString(); Agencytxt.Text = SelectedAgency; Agencytxt2.Text = SelectedAgency; Agencytxt3.Text = SelectedAgency;DbDataReader CollectingDataSelected = null; try {CollectingDataSelected = ConnectionFinanceDB.CollectedFinaceData("SELECT DISTINCT AGENCY_ID FROM dbo.AIMS_AGENCY where Program = '" + SelectedAgency + "'"); } catch { }DataTable TableSet = new DataTable(); TableSet.Load(CollectingDataSelected, LoadOption.OverwriteChanges);int IndexingValues = 0;foreach (DataRow DataCollectedRow in TableSet.Rows) {if (IndexingValues == 0) {SQLCONDITION = "where (Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'"; } else {SQLCONDITION = SQLCONDITION + " OR Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'"; } IndexingValues += 1; }SQLCONDITION = SQLCONDITION + ")"; ConnectionFinanceDB.DisconnectToDatabase();if (Dataviewlisting.ActiveViewIndex == 0) { Dataviewlisting.ActiveViewIndex += 1; } else { Dataviewlisting.ActiveViewIndex = 0; } SelectedAgency = SQLCONDITION; ValueSelected.CONDITION = SelectedAgency;
???? this is where i use to get count where in other buttons and are displayed.... but i changed the query to display only the Payment_Amount_Budgeted respective to the agency selected. from the viewRUN_SQLCONDITION = "SELECT Payment_Amount_Budgeted FROM dbo.V_Payment_Amount_List " + SQLCONDITION; try { CollectionCount = ConnectionFinanceDB.CollectedFinaceDataCount(RUN_SQLCONDITION); EnrollAmtBTM.Text = CollectionCount.ToString(); } catch { }////this is my CollectedFinaceDataCount-- where fuction counts the records in the above select statement if i use for eg. "SELECT Count(Placement_Retention_ID) FROM dbo.V_Retention_6_Month_Finance_Payment_List" here is the functionpublic int CollectedFinaceDataCount(String SQLStatement) {int DataCollection; DataCollection = 0; try { SQLCommandExe = FinanceConnection.CreateCommand(); SQLCommandExe.CommandType = CommandType.Text; SQLCommandExe.CommandText = SQLStatement; ConnectToDatabase();DataCollection = (int) SQLCommandExe.ExecuteScalar(); DisconnectToDatabase(); }catch (Exception ex) {Console.WriteLine("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString()); } return DataCollection; }
So here mu requirement request is to display only the value fronm the view i have against the agency selected Please help ASAP Thanks Santosh
Hi,I have a DataGrid whose DataSource is an SQLDataSource. This SQLDataSource references a SQL Server table with an Identity column, named Id. The SQLDataSource has generated an Update statement for me, but this only works if the Id column is selected for display in the DataGrid, and has Visible = True. If not, then the @original_Id parameter to the generated Update statement has a value of Nothing, and the Update has no effect. So is there a way to enable the Update statement to work, without the user having to see the Id column in the DataGrid? Many thanks,Keith.
Ok here goes. I have 3 tables, one holds case info, the 2nd holds possible outcome on the charges, and they're joined on a 3rd table (CaseOutComes). With me so far? Easy stuff, now for the hard part. Since there's a very common possiblitly that the Case has multiple charges, we need to track those, and therefore, display them on a datagrid or some other control. I want the user to be able to edit the info and have X number of dropdowns pertaining to how many ever charges are on the case. I can get the query to return the rows no sweat, but ...merging them into 1 record (1 row) with mutiple drops is seeming impossible -- I thought about using a placeholder and added the controls that way, but it was not in agreement with what I was trying to tell it . Any ideas on how to attack this?
This is my case. I want in my datagrid to display first record from table A and second record from table B. This is because i need to display a price in the column where it will have current price and history price, therefore the first row will be current price and second row will be history price.
This is the output that i trying to do.
Item | Price -------|--------- A | 2.50 --------> Table A A | 1.50 --------> Table B
Please let me know if my explanation is not details enough.
Hi Guys, I have a sql procedure that returns the following result when I execute it in query builder: CountE ProjStatus 6 In Progress 3 Complete 4 On Hold The stored procedure is as follow: SELECT COUNT(*) AS countE, ProjStatusFROM PROJ_ProjectsGROUP BY ProjStatus This is the result I want but when I try to output the result on my asp.net page I get the following error: DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name Count. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name Count.Source Error:
Line 271: </asp:TemplateColumn> Line 272: <asp:TemplateColumn> Line 273: <itemtemplate> <%# DataBinder.Eval(Container.DataItem, "Count" )%> </itemtemplate> Line 274: </asp:TemplateColumn> Line 275: </columns> My asp.net page is as follows: <script runat="server"> Dim myCommandPS As New SqlCommand("PROJ_GetProjStatus")
' Mark the Command as a SPROC myCommandPS.CommandType = CommandType.StoredProcedure Dim num as integer num = CInt(myCommand.ExecuteScalar) 'Set the datagrid's datasource to the DataSet and databind Dim myAdapterPS As New SqlDataAdapter(myCommandPS) Dim dsPS As New DataSet() myAdapter.Fill(dsPS)
Hay Friend's Can u plese send me the way how to save image in sql server and display that images in datagrid or other control also like Image control or Image control Button?? Plese send the coding in C#. Thank's Amit
I am developing a system for my uni course and I am stuck a little problem...
Basically its all about lecturers, students modules etc - A student has many modules, a module has manu students, a lecturer has many modules and a module has many lecturers.
I am trying to get a list of lecturers that run modules associated with a particular student. I am able to get a list of the appropriate lecturers, but some lecturers are repeated because they teach more than one module that the student is associated with.
How can I stop the repeats?
Heres my sql select code in my cs file:
string sqlDisplayLec = "SELECT * FROM student_module sm, lecturer_module lm, users u WHERE sm.user_id=" + myUserid + "" + " AND lm.module_id = sm.module_id " + " AND u.user_id = lm.user_id "; SqlCommand sqlc2 = new SqlCommand(sqlDisplayLec,sqlConnection); sqlConnection.Open(); lecturersDG.DataSource = sqlc2.ExecuteReader(CommandBehavior.CloseConnection); lecturersDG.DataBind();
And here is a pic of my Data Model: Data Model Screenshot
Any one tell me the best process to bind the data to datagrid?I am using this method,it is taking lot of time to fill data to datagrid.
conn = new SqlCeConnection("Data Source=\sample.sdf; Password =''"); dt = new DataTable(); da = new SqlCeDataAdapter(Quary, conn); da.Fill(dt); DataaGrid1.Datasource=dt;
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?
VB.NET 2003 / SQLS2KThe Stored Procedure returns records within Query Analyzer.But when the Stored Procedure is called by ADO.NET ~ it produced thefollowing error message.---------------------------Exception Message: Failed to enable constraints. One or more rowscontain values violating non-null, unique, or foreign-key constraints.------------------------------------------------------Exception Source: System.Data---------------------------If I click OK past the error messages I will get data filling thedatagrid. However not as I would like to see it.Even though it returns the proper data rows and includes all thecolumns I asked for, it also returns plenty of columns I didn't ask for(all the columns of the main table) and all those columns are filledwith "null"In addition each row header contains a red exclaimation mark whch whenhovered over reads;"Column 'cmEditedBy' does not allow DBNull.Values."An interesting thing about this column 'cmEditedBy' is that there isnoting wrong with it and all rows for that column contain data.I believe this error is a mistake! But it probably indicates some otherproblem. How should I track its cause?M O R E ...Below is the code in the data layer, the stored procedure, and the datareturned within query analyzer.\'DataAdapterFriend daView041CmptCyln As New SqlDataAdapter'SqlCommandPrivate daView041CmptCyln_CmdSel As New SqlCommand'Add the commanddaView041CmptCyln.SelectCommand = daView041CmptCyln_CmdSel'SelectWith daView041CmptCyln_CmdSel.CommandType = CommandType.StoredProcedure.CommandText = "usp_View_041Cmpt_ByJobCyln".Connection = sqlConnWith daView041CmptCyln_CmdSel.Parameters.Add(New SqlParameter("@RETURN_VALUE", SqlDbType.Int, _4, ParameterDirection.ReturnValue, False, CType(0,Byte), _CType(0, Byte), "", DataRowVersion.Current, Nothing))'Criteria.Add("@fkJob", SqlDbType.Text).Value = _"48c64a55-874d-40d0-addc-7245f5d9c118"'.Add("@fkJob", SqlDbType.Text).Value = f050View.jobIDEnd WithEnd With//\ALTER PROCEDURE usp_View_041Cmpt_ByJobCyln(@fkJob char(36))AS SET NOCOUNT ON;SELECTJobNumber,DeviceName,ComponentName,Description,Quan,Bore,Stroke,Rod,Seconds,CylPSI,PosA,PosB,PosC,PosD,PosE,HomeIsRet,RetIsRetrac,POChecks,Regulated,FlowControl,PortSize,LoadMassFROM tbl040cmptINNER JOIN tbl030Devi ON fkDevice = pkDeviceIdINNER JOIN tbl020Proc ON fkProcess = pkProcessIdINNER JOIN tbl010Job ON fkJob = pkjobIdINNER JOIN lkp202ComponentType ON fkComponenttype = pkComponentTypeIdINNER JOIN lkp201DeviceType ON fkDeviceType = pkDeviceTypeIdINNER JOIN lkp101PortSize on cmSmallint05 = pkPortSizeIdWHERE(fkJob = @fkJob)--fkJob = '48c64a55-874d-40d0-addc-7245f5d9c118'AND fkComponentType = 2GO//(note - columns are wrapped)\F1111Clip DriverCylinderClip Driver_2 - Top -Cylinder91.2502.250.8752.250NULL01101110011/8 NPTNULLF1111Punch MechCylinderPunch Mech_1 -Cylinder_222.1002.0001.0001.234NULL11000110011/8NPTNULLF1111ClipDriverCylinderBottom92.1002.0001.0001.000NULL11010110011/4NPTNULLF1111Punch MechCylinderPunch Mech_1 -Cylinder_122.1002.0001.0001.000NULL01000110011/8NPTNULLF1111DegateCylinderDegate 1 -Cylinder21.1882.500.8751.000NULL11000110011/8 NPTNULLF1111Clip DriverCylinderClip Driver 1 -Bottom11.1801.250.8751.000NULL00011110011/4 NPTNULL//
New to SQL Server Compact Edition and I am getting my feet wet with the following tutorial: http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20060831MobileRB/manifest.xml
I follow the tutorial exactly, but the data I edit through the Edit Dialog Form is not saved to the SQL Server table even though all of the edits appear in the datagrid. They never make it back into the table.
I'm still fairly green when it comes to ASP.NET and SQL Server, but I have written my share of cool applications (for personal use), using MS ACCESS. Needless to say, I'm growing beyond the limitations of ACCESS. Since I don't have the cash to spend on SQL Server, I downloaded WebMatrix and MSDE. I can connect and create databases with no problems. I just have a basic question: Is it possible to use SQL Server Authentication with MSDE, or is it limited to Windows Authentication? If there's a way, how would I go about it?
I'm trying to learn a little C#, and SQL using SQL Express, Microsoft SQL Server 2005 - 9.00.951, and Web Matrix v0.6 buld 812 with .Net Framework v2.0.40507.42.
Does Web Matrix and .Net v2 work with SQL Express ?
sqlcmd and xm work allow me to select from my table okay, but cannot do so using my aspx SQL code. It appears the SQLConnection is the culprit:
SqlConnection c = new SqlConnection("server=localhost;Trusted_Connection=Yes;database=test");
(I have tried adding uid=;pwd=; and still get same error.)
Next line of code after connection is:
SqlDataAdapter co = new SqlDataAdapter("select field1 from testtable", c);
Note that error message below refers to line 18, co.Fill..., but I believe its theSQLConnection code that is failing.
Always get error: Server Error in '/' Application.
Named Pipes Provider: The system cannot find the file specified. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Named Pipes Provider: The system cannot find the file specified.
Source Error:
Line 16: DataSet d = new DataSet(); Line 17: // Line 18: int i = co.Fill(d, "x"); Line 19: Response.Write(i.ToString()); Line 20: l.DataSource = d; // d.Tables["x"].DefaultView;
Source File: c:My Work FilesMicrosoft RelatedSQLexpressa.aspx Line: 18
I've just started to learn ASP.net using Scott Mitchell's book:ASP.NET in 24 hours. But i've got a little problem in the database section. I couldn't connect with a MSDE from webmatrix using sql server authentication even the username and password are correct. The error message : "unable to connect to the database server:Login failed for user 'sa'. Reason:not associated with a trusted SQL server connection". What does it mean? Have any of you ever had this kind of problem? Thank you for helping me.
I have downloaded WebMatrix/NET.Framework and it works well. Unfortunatelly I have problem with connecting to MSDE. I've installed the new version (sql2ksp3a) like they say:
The MSDE works ok (I can connect from a commercial programs - for example 'MSDE Manager') and seems to be ok. But when I try to connect from Web Matrix I get the error: "Unable to connect to database, Invalid connection connection Open, Invalid instancename".
I put all the parameters correct: user: sa, auth.type: SQL, server: my_pc_namemy_instance_name
By the way the instance name and my PC name is the same. Could it be the reason ?
get a prompt up (in a program like telnet / msdos window) so that I can run sql commands on my webmatrix accounts sql server. I've been trying to connect using telnet but i think maybe I've got the wrong end of the stick or I'm doing something wrong.
here's a link where you click through "how to connect" on the "myserver page" I searched the page for "connect" and found 0 occurances.
Hi all, i'm making a webpage via the walkthrough of webmatrix. I use the tutorial 'Build an End-to-End Application (with C#.NET) '. The problem is that this tutorial works with an access db. I'll try to start the same thing but using an sql server.
Nowhere i can't find (because i don't look at the right place i gess) how i have to make a sqlconnection via webmatrix with c# using a keyfield to filter my data and to fill out a datagrid.
I just recently DL'd sql server 2005 Express and set up it on a server and it works. However, I do my development on my desktop with Webmatrix and can't seem to connect to it. Webmatrix tells me I must use SQL server management studio or SQL server management objects (SMO). Am I barking up the wrong tree?
I am trying to display hirearchical data using data region. For eg. the first level will be a list of customer names. The second level will be a list of Invoices under each customer. The third level will be a list of product names that were sold under each invoice.
I used a list for the data region and in each hireachy, there is a textbox in each list to display the data. I am trying to associate each data region with a datatable (I will provide the logic to populate the datatable with appropiate data). I do not want the ReportViewer to interact directly with a database because this is a 3 tier design and I am using the ReportViewer in local mode. I couldn't find any example of these. Can anybody help? Also I would like to see an example of the .rdlc file in these situation. Thanks very much.
I've always bound data to a dataset...how do I display data without a dataSet? This is how i usually display data... SqlConnection myConnection = new SqlConnection(conn); string sqlQuery = "SELECT * FROM questions"; SqlDataAdapter myCommand = new SqlDataAdapter(sqlQuery, myConnection); DataSet ds = new DataSet(); myCommand.Fill(ds, "questions"); MyDataGrid.DataSource = ds.Tables["questions"].DefaultView; MyDataGrid.DataBind(); <%# DataBinder.Eval(Container.DataItem, "answer3")%>
Hi All I am new to VS 2005 and ASP.NET. I used to use Dreamweaver to design but now I am trying VS. What I want to do is to display data retrieved with a SqlDataSource in a web page. I know how to do it by binding it to the various controls (Grid, DataList, DetailsView, FormView, Repeater.) available but how can I display it without using any of the mentioned (Grid, DataList, DetailsView, FormView, Repeater)? Any help apprecited.
Hi, I have stored procedure with cursor I have to use following step 1 fetch RateValidDates into @Id_RateCode, @TheValidDate .... get data
step 2 fetch prior from RateValidDates ... condition
step 3 fetch NEXT FROM RateValidDates into @Id_RateCode, @TheValidDate ... go to next record
Sql query analyzer output result of fetch NEXT FROM on the screen What seeting should i use to avoid output on screen (The reason My cursor takes about 8000 - 10000 rows when it's open)
When I select a table and try to view the data I take the return all rows or return top option. However nothing is displayed. These options worked before and I don't understand why it's not working now. Can anyone help?
I have data in rows that I need to aggregate and display in a columnar fashion and I haven't been able to figure out how to do it. A simplified version of the data as it is stored in the table:
Station Month Day Reading
1 1 1 100
1 1 2 200
1 1 3 300
1 2 1 400
1 2 2 500
And I would like to create a query that returns:
Station Month Day 1 Day 2 Day 3
1 1 100 200 300
1 2 400 500
Any help you can provide or tips to steer me in the right direction are much appreciated.
I am using a filter in a matrix control. I would like to display a "No data" type message if no data is present. The problem I'm running into is the base query is returning data, but the optional filter is removing all rows from display.
So using CountRows in the base dataset doesn't quite cut it. Is there an alternative?