Hi all,I asked a similar question a few weeks ago but I didn't explain myself to well so I was hoping for some more input.I have created a webpage in Visual web developer that contains a gridview that points to an SQL table.All works well as far as searching the table and sorting. The SQL table itself is Droped ( deleted ) and then re-created every 1 minute from a query to a linked DB2 database so that we have a "live" table of our DB2 system but in SQL.....However,There is now a requirement to be able to ADD data to this SQL table. eg: a comments field.. from the website.My procedure for re-creating the SQL DB is now useless as any data added through the website would be lost when the table gets re-created.What is the best way for me to achieve a permanent table in SQL that gets updated from the Linked server DB2 but that I can also add comments from the front end (Website Gridview)..I'm assuming some sort of update query and a join to a seperate, permanent table that contains the comments?.Please help. Ray..
hiii, i am using asp.net 2005 and sql server 2005...i hav a page in which i have used gridview and sql data source..i have written the update command for the same..the problem is when i add the where clause in the query i get an error ,,,,here is the code
UpdateCommand="UPDATE SMEtre_Master SET FirstName =@FirstName, LastName =@LastName, Type_of_SME =@Type_of_SME, Agency_Name =@Agency_Name, Email =@Email, Address =@Address, Phone =@Phone, Mobile =@Mobile, Fax =@Fax, Experience =@Experience, City =@City, State =@State where SME_Id=@SME_Id"
I put a grid view on a web form ,when I run it -the SELECT, EDIT works the UPDATE,DELETE makes an error although I use the sama data,I added the error : Anyone can help?
Server Error in '/CrystalReportsWebSite1' Application.
The data types text and nvarchar are incompatible in the equal to operator. 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: The data types text and nvarchar are incompatible in the equal to operator.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
Hi ! I have a textbox and a Search button. When the user inputs a value and press the button, i want a datagrid to be filled. The following code runs: Dim connect As New Data.SqlClient.SqlConnection( _ "Server=SrvnameSQLEXPRESS;Integrated Security=True; UID= ;password= ; database=dtbsname") connect.Open() Dim cmd As New SqlCommand Dim valor As New SqlParameter("@valor", SqlDbType.VarChar, 50) cmd.CommandText = "Ver_Contactos_Reducido" cmd.CommandType = CommandType.StoredProcedure cmd.Connection = connect cmd.Parameters.Add(valor) cmd.Parameters("@valor").Value = texto Dim adapter As New SqlDataAdapter(cmd) Dim ds As New System.Data.DataSet() adapter.Fill(ds) GridViewContactos.DataSource = ds GridViewContactos.DataBind() connect.Close() I drag a datagrid on the page and only changed its Id. Into the SQL database the stored procedure is the following: ALTER PROCEDURE [dbo].[Ver_Contactos_Reducido] (@Valor VARCHAR(100)) AS BEGIN SET NOCOUNT ON; SELECT NombreRazonSocial, Nombre, Apellido,TelefonoLaboral, Interno, TelefonoCelular, Email1, Organizacion FROM CONTACTOS WHERE NombreRazonSocial = @Valor OR Nombre = @Valor OR Apellido = @Valor OR TelefonoLaboral = @Valor OR Interno = @Valor OR TelefonoCelular =@Valor OR Email1 = @Valor OR Organizacion= @Valor END When i run the page i can't see the datagrid, and after i enter a text and press the button, nothing happens. What am i doing wrong?? Thks!!
I am looking for a way to create a stored procedure that will show inventory availability. I would like to show the Inventory Name, The Date, and if the inventory is "checked out" using the ID name of the person who has the item.
For example it would look like this:
-------------------------------------------------------------------------------------------------- Inventory Name | 10/24/2015 | 10/25/2015 | 10/26/2015 | 10/27/2015 | 10/28/2015 -------------------------------------------------------------------------------------------------- Laptop | Tom | Tom | Tom | Avail | Avail Projector | Avail | Avail | Avail | Avail | Bob Air Card | Bob | Bob | Bob | Bob | Bob
It seems like I want to do a pivot table but there really is no aggregate so I am not sure what to use.
hi,i have an sql database on my server on the world wide web.i can make a connection to the database in visual web developer and all the tables etc are shown in the 'database explorer' of visual web developerwhen i make the query in visual web developer it does retrieve the data froom the remote server database when i 'test query'.... so looking great!the connection string in the webconfig file is left as the default when i run the prgram on my LOCAL HOST with the inbult server that comes with visual web developer it runs fine......so.....running on my local pc it will connect to the database on my www host server and does display the data from that database.i need to change the webconfig files path to the connection by default it is |DataDirectory|if i change this to the path i suspect is correct as this is the connection i use to the database C:Inetpubvhostsarcvillage.comhttpdocsApp_DataTestdatabase.mdfwhen i change the path in webconfig then it stops working on my localhost and the error when i ftp it to my host is:Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed. any ideas?
I have the membership stuff up and running. I've added a field to the membership table called custnmbr. Once a user logs in, I want store his custnbmr in the session and use that to lookup data in another db. ie: Joe logs in and his custnumbr is 001, he goes to the login success page and sees his list of service calls which is: select top 10 * from svc00200 where custnmbr = 001 (the membership.custnmbr for the logged in user) I know how to do this in old ASP using session variables....but I have no idea where to even start with .Net. Many thanks
hi, i have done some testing and its only when i put a grid view or any other type of data viewer on the page, and then connect it to the sql datasource that i get an error Line 1: Incorrect syntax near ')'. now i really cant figure out what it is, here is the code i am using SQL data source code : asp:SqlDataSource ID="SQLDS_view_one_wish" runat="server" ConnectionString="<%$ ConnectionStrings:wishbank_DBCS %>" SelectCommand="SELECT [msg], [Date_Time] FROM [tbl_MSG] WHERE (([Activated] = @Activated) AND ([msgID = @msgID]) )ORDER BY [Date_Time] DESC"> <SelectParameters> <asp:Parameter DefaultValue="Y" Name="Activated" Type="String" /> <asp:SessionParameter Name="msgID" SessionField="sWV" Type="String" /> </SelectParameters> </asp:SqlDataSource>
session variable code which sends it to this page protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = GridView1.SelectedRow; Session["sWV"] = row.Cells[1].Text; Response.Redirect("www/viewwf.aspx"); }
if you have an idea please let me know as im stuck!
Inside my gridview, the user can key in new record, delete record and update record. but dont know why my insert function cant work out and i dunno why this is happen? Can somebody help me out with this?Thanks My Code:<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"InsertCommand="INSERT INTO [rest_info] ([resname], [menu], [price], [date]) VALUES (@resname, @menu, @date, @price)"<InsertParameters> <asp:Parameter Name="resname" Type="Char" /> <asp:Parameter Name="menu" Type="char" /> <asp:Parameter Name="price" Type="Decimal" /> <asp:Parameter Name="date" Type="datetime" /> </InsertParameters></asp:SqlDataSource>
i seem to have problems with my grid view not displaying anything when if i test my SQLDataSource, it shows me rows of data.i seem to have this problem only with my Stored procedure, or when i change my Database structure, like add fieldsHere is my procedure: can i do this? select a row and also return a varchar?ALTER PROCEDURE dbo.SelectUpload ( @FileName varchar(50), @Return varchar(MAX) = NULL OUTPUT ) AS SELECT * FROM Uploads WHERE FileName = @FileName
RETURN SELECT WebPath FROM Uploads WHERE FileName = @FileName
I have gridview bound with SqlDataSource control. One of the grid columns is a dropdown list which is populated programatically, (the gridview has template column with edittemplate field with dropdown list), dropdown Value contains of course collection of IDs.Please tell me how to declare UpdateCommand which will update the row with the dropdown list. The problem is with parameter regarding the column with dropdown list. When i declare this parameter and bind it to SelectedValue property of the dropdownlist from edittemplate tag - it doesnt work, because datasource control cannot see this dropdown list. So, how am i supposed to declare the ID of the row being updated in <updateParameters>? Thanks in advance!
Hi there. I looked through many other posts describing scope_identity but I am trying to achieve the same thing from the code behind. i.e. I need to some how call a method to execute the insert command and then return the ID so I can update other tables with this value. I was going down the road of something like: addnew as sqldatasource = new sqldatasource addnew.insertcommand = "Insert into....; def @NewID as scope_identity" addnew.insert()
The problem is I don't know how to add a output parameter using VB or how to retrieve it. Any help would be much appreciated, this is doing my head in.... Doug.
I have consistent column names that load into a grid view. I now need to change the names in the grid view programatically. I was originally trying to get cute with SQL to do this, but I've been told my below solution will not work and I'm better off to do this in the presentation layer. If this is true, remember I'm still wet behind the ears here...how do I do this in vs2005? Here's my post to the SQL devs to give you an idea what I'm trying to do. I have a query that grabs fields from a denormalized table. The result is column names Week1, Week2, Week3....Week26. Users want to see the actual date instead of Week#. So I have a table (lkpdatecaptions ) that contains the fields "fldfieldno" and "Fldcaption". fldfieldno Fldcaption----------- --------------11 9/07/200712 9/14/200713 9/21/2007So fieldno 11 represent week1 and so on. So my hope is to update the alias with a query like: Select fldcaption from forecast.tlkpdatecaptionswhere fldfieldno = 11That quey returns the value of 9/7/2007 and is the value I need to represent the coumn alias name.My current query looks like this:SELECT SUM(forecast.tblforecastdenormalized.fldwk01) AS WEEK1,So can I do something like the following?SELECT SUM(forecast.tblforecastdenormalized.fldwk01) AS (Select forecast.tlkpdatecaptions.fldcaption from forecast.tlkpdatecaptions where fldfieldno = 11), ...
Hello,I have inserted a drop down list in my Edit template of Grid view. This DDL should control the User_ID who is responsible for the Computer being edited. However I want it to display the User Names rather than the user IDs. I have a COMPUTERS and a USERS table. They are related by having User_ID in both. Below is my grid view with the parts i feel relative highlighted in bold:<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Computer_ID" DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <Columns> <asp:CommandField ShowEditButton="True"/> <asp:BoundField DataField="Computer_ID" HeaderText="Computer_ID" InsertVisible="False" SortExpression="Computer_ID" ReadOnly="true" /> <asp:BoundField DataField="Computer_Name" HeaderText="Computer Name" SortExpression="Computer_Name"/> <asp:BoundField DataField="Manufacturer" HeaderText="Manufacturer" SortExpression="Manufacturer"/> <asp:TemplateField HeaderText="User Name" SortExpression="Name"> <EditItemTemplate> <asp:DropDownList ID="DDL_Name" runat="server" DataSourceID="SQLDataSource2" DataValueField="User_ID" SelectedValue='<%# Bind("User_ID") %>'></asp:DropDownList> </EditItemTemplate> <ItemTemplate> <asp:Label ID="lblName1" runat="server" Text='<%# Bind("Name") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="Data Source=.SQLEXPRESS;AttachDbFilename=C:AjaxControlToolkitWebSite1App_DataAssetDatabase.mdf;Integrated Security=True;User Instance=True" ProviderName="<%$ ConnectionStrings:AssetDatabaseConnectionString.ProviderName%>" SelectCommand="SELECT * FROM USERS" > </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=.SQLEXPRESS;AttachDbFilename=C:AjaxControlToolkitWebSite1App_DataAssetDatabase.mdf;Integrated Security=True;User Instance=True" ProviderName="<%$ ConnectionStrings:AssetDatabaseConnectionString.ProviderName%>" SelectCommand="SELECT COMPUTERS.Computer_ID, USERS.User_ID, COMPUTERS.Computer_Name, COMPUTERS.Manufacturer, USERS.Name FROM COMPUTERS INNER JOIN USERS ON COMPUTERS.User_ID = USERS.User_ID" UpdateCommandType="StoredProcedure" UpdateCommand="StoredProcedure1" > <UpdateParameters> <asp:Parameter Name="Computer_ID" Type="Int32" /> <asp:Parameter Name="User_ID" Type="Int32"/> <asp:Parameter Name="Name" Type="String" /> <asp:Parameter Name="Computer_Name" Type="String" /> <asp:Parameter Name="Manufacturer" Type="String" /> </UpdateParameters> </asp:SqlDataSource> <br /> <br /> </form></body></html> THANKS =]
I am working on a school project and have come up against a bit of a sticking point. I am supposed to be creating a very basic OMS, the teacher themselves have said they do not know how to do this (in previous years it has all be done via Access) but apparently I am a lucky one to be doing it in SQL this year.
One of the user requirements of the OMS is to fill a data grid with product name and the product details which I have the query for or rather I have created a view for, which is then queried from a stored procedure.
CREATE VIEW [dbo].[v_stock] AS SELECT tab_products.productname, tab_productdetails.description, tab_productdetails.image, tab_productdetails.price, tab_productdetails.stock FROM tab_productdetails INNER JOIN tab_products ON tab_productdetails.productid = tab_products.productid
The problem I am having is then returning the data from this query into a data grid, I think the reason is because when I attached the stored procedure to a table and then call that procedure via the table adapter there is a mismatch of the schema - specifically the table it is attached to does not contain the column "productName".
I am thinking I need to create a temporary table to fill the data grid with - however, I am not sure how I would create a temporary table.
Is there something I am missing or not done correctly. As far as I can tell the queries work as when I preview them they produce the expected results.
what datafield shoud i put in my database if its a checkbox option? coz in my datagrid i added a checkedbox so that i can easily manipulate it.but when i run it. it produces error. and doesnt recognize the checkbox column.it said that there none in the datasource.but i dont know what should i put in the database! pls help!thanks
I've created a Data Set with a connection string to my sql database however when i go to create queries and select 'generate update, delete and insert statements' it doesn't do it. I'm wondering why and how do i get this fixed since i don't know how to code it myself.
I need to display data from a sql server 2000 db on an asp web page and I need a vertical split. Does anyone have any solutions? I really can't afford to spend much/any money so freeware/shareware or coding suggestions is what I am interested in.
Hi I want to update the grid which in turn will load data to a few tables: the main table and it's lookup tables, I want to write a stored procedure that will check if the data from lookup table already exists and if not it will insert it but I am only starting to get to know stored procedure structure could you give me some advice on how to write such procedure I would be veeeery gratefull
I have the following code: Imports System Imports System.Data.SqlClient
Namespace TestWeb
Partial Class araging
Inherits System.Web.UI.Page
Private _dt As DataTable Private _connstr As String
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub
#End Region
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim _connstr As New SqlConnection(ConfigurationManager.ConnectionStrings("ESQLConn").ConnectionString)
Dim sqlCommand As SqlCommand = New SqlCommand("csp_rpt_ack_form", _connstr)
Dim ds As New DataSet objaDapter.Fill(ds) mainGrid.DataSource = ds mainGrid.DataBind()
Response.Write(_connstr)
End Sub
End Class
End Namespace I am trying to pass a value to the parameter that it contains. What Im I doing wrong? I keep on getting the following message."An SqlParameter with ParameterName '@v_order_doc_no' is not contained by this SqlParameterCollection." Thanks guys!
I try to find the way to create editable data grid (a view from MySQL database) in a web page. So, user can edit, add, or delete from one page instead of having switch edit, insert pages, one field in the view only. Any script I need to write or any special server behavior I can use?
I have a table which stores all prices for companies daily trading. Companies ABC & XYZ have information available for what was the high & low values for a DateID.
CREATE TABLE [dbo].[TestGrid] ( [ID] [int] IDENTITY(1,1) NOT NULL, [CompanyName] [varchar](200) NOT NULL, [DateID] [int] NOT NULL, [High] [float] NOT NULL, [Low] [float] NOT NULL
[code]...
What I'm trying to do is turn the DateID into columns and then as a additional change those columns represent the actual day of the Date ID How would i know 20121201 is equal to say Monday and 02 is Tuesday?
END RESULT:
NAME TYPE MONDAY TUESDAY WEDNESDAY ABC HIGH 0.5 0.6 1 ABC LOW 0.1 1.5 0.6
I have table in sql server for Employee, it has(id, Employee, director),so the director field is id of the director's name, so the director is employee and has director also, only the first director hasn't director( one Employee has not director);now, i want to use datagridviewer in c# for display as this table (id, employee, director), so the first record will be the (id, employee, ' ');i use this query:"select emp.ID ,emp.Name ,dir.Name as'director' from table1 emp, table1 dir where (emp.director=dir.ID OR dir.director IS NULL)"but when i display the datagridviewer , it don't display the first employee(first director) which hasn't director.
Has anyone ever looked at the way the grid data viewer sorts it data when clicking on a column header? If you click on a column header, something happens to the sorting of the data in the viewer, but it's not always clear to me _what_ is happening. It appears the data is sorted ascending on the column you clicked on. If you click again the sort order seems to inverse to descending. However, if you look closely, it turns out that the data is not always sorted correctly, especially when you click on an integer valued column.
I found this when doing a demo on the AdventureWorks demo extracting data from the SalesOrderDetail table. If you sort on the OrderQty column, data is correctly sorted in ascending quantities. However, if you click the column again, orders with an order quantity of 2 are displayed on top (while there are orders with a much higher order quantity) and if you scroll down the list, you notice that there is no clear sorting anymore. The same happens with other columns.
Is this supposed to work as I would expect it to do or is there a logical explanation for the behaviour I see?
-- Best regards,
Hans Geurtsen Docent Kenniscentrum
Info Support De Smalle Zijde 39 3903 LM Veenendaal The Netherlands www.infosupport.nl
I am sending a GUID to a form via the query string. If it exists I use helper functions to load most of the form text boxes. However, if it does not then a blank form is presented and the GUID is stored in a hidden field. Regardless, I use this hidden field to populate a grid that is attached to a sqldatasource. If I then add new datarows to the backend database programmatically, I cannot 'requery' the datasource to include those row upon a postback. I cannot seem to find a simple way to force the sqldatasource to rerun the query. Can anyone help.
We are building a near real time application in Windows Forms, that stores data in SQL Compact Edition. The client receives messages via UDP socket and performs insert / update operations to the db accordingly, and the requirement is to update a data grid with the changes.
We tried querying the db and receive a ResultsSet which is sensitive and scrollable, and bind a ResultSetView to the Grid. But, since the updates are made from another thread, the grid is not being refreshed.
What is the best approach for achieving this?
Thanks in advance,
Guy Burstein http://blogs.microsoft.co.il/blogs/bursteg