Hi all I have a form view which uses a SQL data source control to retrieve it's data from the sql express database the form view is used for view,edit,delete and insert data into the database in the insert mode I have two dropdownlists, where the second one is depending on the first one to retrieve the correct data from the data base BUT when selecting a value in the first dropdownlist it give me the following erro: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Please How can do this any help is appriciated bye
Hey guys, Am in need of help please, basically the program im working with at the moment is when you add a New Contract, it will grab the Contract Number you have entered, Post it over to another page, then using that number bind a Gridview. The SQL being "SELECT Contract_ID, Contract_Number, Start_Date, End_Date, Quarterly_Rent FROM ECS_Contracts_Test WHERE Contract_Number = " & conNoVar (this being the Contract Number of the recently added Contract), however then it comes to Bind the Grid it kicks up an System.Data.SqlClient.SqlException: Syntax error converting the nvarchar value '2009P7899' to a column of data type int.But the Column Contract_Number is set to Varchar and all I really want to do is to create this gridview using this criteria and not convert anything! The Contract_ID is an int, which is needed as I increment it. Heres the error code: Public Sub BindtheGrid()'Bind the Contract Grid, where ContractID is used Dim SQL As String = "Contract_ID, Contract_Number, Start_Date, End_Date, Quarterly_Rent" Dim objConn As SqlConnection = New SqlConnection(ConnectionString) Dim cmdstock As SqlCommand = New SqlCommand("SELECT " & SQL & " FROM ECS_Contracts_Test WHERE Contract_Number = " & contractQueryID, objConn) cmdstock.CommandType = CommandType.Text objConn.Open() GridView1.DataSource = cmdstock.ExecuteReader() GridView1.DataBind() objConn.Close() End Sub If you need any more information then please let me know. Mucho Aprreciated
Hi guys, I am about to bind my websites user inputted values into my database. I intend to use sql for this. THe site is very basic, dropdownlists and textboxes. The user is required to choose values and write in questions. Now these inputs ought to be stored somewhere right??, so for that i am using sql. Now i know sql, but how do I store data from a website and all, I have no clue, someone give me basic steps on how to go about doing this pleaseeeeee!!!
i want to count the number of times a particular data occurs in a table and display that data in a listbox
initially i planned to count the number of occurrences and bind that number to a variable for further manipulation but i have no idea how to do the binding part
I am new to .net and I am using Visual Web Developer 2005 Express with SQL Server 2005 Express. What I would like to do is connect to my SQL database (which resides in the app_data folder) and open a table and pull out a field and place it in either a textbox or label on the page. No editing or deleting. Just simple one field binding. By the way, I can do this with all the cool built-in tools of VWD, but I want to know how to do it all by hand. I would really appreciate it if someone could help me out.
I have search for answers to the all over google and every thing I have found so far did not work for some reason or anothr. . Here is what I am looking for I am codeing in Visual Studio using C#. I have been able to crate a connection and create taxt boxes with a submit button that when it is presed enters data in to a database (Sql server) what I have been unable to do is: 1. Display data in a text box. 2. Update data 3. create buttons to navagate through fields. I know I can do this with the gridview or datagrid but in really need a custome form for what I am doing.
I am using C#.Net, Visual web Developer, SQL server 2000. I have a SQL query which I am binding it to a DataGrid. SQL : "SELECT ord_number, ord_ID, ord_split, ord_Name, ETD_Date, OSP_FSD FROM ORDERS" In My DataGrid I have a dynamic databound column. I am able to bind one column to this databound column using following code. BoundColumn ETDDate = new BoundColumn(); ETDDate.HeaderText = "ETD Date"; ETDDate.DataField = "OSP_FSD"; mygrid2.Columns.AddAt(ETDDate); but now I want to bind this databound column based on the following criteria to two different database columns. if(ord_split = 1) { ETDDate.DataField = "OSP_FSD"; } else { ETDDate.DataField = "ETD_Date"; } How to get value of ord_split before binding SQL to teh DataGrid? i.e I just want to take value of ord_split and not all the values of SQL. Please Help!
This is an easy question. I thought I have databinded a textbox to a SQLDataSource. But now I do not see how to do that now. Can somebody help with this? Thanks,
Hi, I wants to bind textbox with sqldatasource in c#.net so I am using following code and has following error... Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:
Line 22: Line 23: System.Data.DataView dv = (DataView) SqlDataSource1.Select(System.Web.UI.DataSourceSelectArguments.Empty);Line 24: TextBox1.Text = dv[0]["Proid"].ToString();Line 25: Line 26: }Please, anybody knows solution tell me
Ok I have a script to generate a database, and newly added to the database is a date fild for a specfic table. I have the 'Default value or binding' set to (getdate()) how exactly would you add that to the script for then the table is initialy generated. Or is it soemthing I would need another script to do right after the table generation.This is the script for the table in question:CREATE TABLE [dbo].[cust_file] ( [id] [int] IDENTITY (1, 1) NOT NULL , [customer_id] [int] NULL , [filename] [varchar] (255) NULL , [filedata] [image] NULL , [contenttype] [varchar] (255) NULL , [length] [int] NULL, [added_date] [datetime] NULL) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]GO Any help would be great,Tim MeersWannabe developer.
I want to bind some data to a text box from sql server db. but when i run the page i get an error. here is my code. <form id="form1" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:imacsConn %>" SelectCommand="SELECT Reportnumber FROM [SummaryBlue] WHERE REPORTNUMBER = @REPORTNUMBER"> <SelectParameters> <asp:QueryStringParameter Name="REPORTNUMBER" QueryStringField="REPORTNo" Type="String" />
Error: Exception Details: System.FormatException: Input string was not in a correct format.Source Error:
Line 25: </SelectParameters> Line 26: </asp:SqlDataSource> Line 27: <asp:TextBox ID="TextBox1" runat="server" Columns="<%$ ConnectionStrings:imacsConn %>"></asp:TextBox></div> Line 28: </form>
Hi i'm a new to ASP.NET and for some reason when i click the Next button in the code below, the pageIndex does not change. Please assist, Basically what i'm trying to do is to use DataAdapter.fill but passing in the start index and the number of records to pull from the dataset table. using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; public partial class Home : System.Web.UI.Page { //ConnectionOleDbConnection dbConn; //discount that can be change by user using a gui interface //CurrentPageint pageIndex = 0;double discount = 0.15 ; protected void Page_Load(object sender, EventArgs e) { // homeGridView.Visible = true;
BindList();
}protected string getSpecial(string price,object sale) {String special = "";if (sale.ToString().CompareTo("True") == 0) {special = String.Format("{0:C}",double.Parse(price) * (1-discount)); }return special; } protected void BindList() { //Creating an object for the 'PagedDataSource' for holding the data.
//PagedDataSource objPage = new PagedDataSource(); try { //open connection openConnection(); //sql commandstring columns = "*"; string SqlCommand = "Select " + columns + " from Books"; //create adapters and DataSetOleDbDataAdapter myAdapter = new OleDbDataAdapter(SqlCommand, dbConn);DataSet ds = new DataSet("bSet");
//create tableDataTable dt = new DataTable("Books");myAdapter.Fill(ds, pageIndex, 9, "Books");
Response.Write("Page Index: "+pageIndex); //create table data viewDataView dv = new DataView(ds.Tables["bTable"]); booksDataList.DataSource = ds; booksDataList.DataBind();
Hi all, The Scenario: Database1:Table1(callingPartyNumber,originalCalledPartyNumber, finalCalledPartyNumber, DateTimeConnect, DateTimeDisconnect, Duration) Database2:Table2(Name,Number) Output in Gridview:
callingPartyNumber Name originalCalledPartyNumber finalcalledPartyNumber dateTimeConnected dateTimeDisconnected Duration (HH:MM:SS) I bind gridview programatically using DataTable and stored procedures. The data comes from a table (Table1) in a database (Database1) on SQL Server. The gridview displays fields callingPartyNumber, originalCalledPartyNumber, finalCalledPartyNumber, DateTimeConnect, DateTimeDisconnect and Duration in this order. All the columns in this gridview are databound columns. I have another table (Table2) in a seperate SQL Server database (Database2) but on the same server which maps the callingPartNumber value with the name attached with that number. Note that the field names in Table2 are different from the field names in Table1. Is it possible to display the Name field also in the gridview after the first field callingPartyNumber and then the other fields. Its like data coming from two tables into the gridview. Thanks
Hi all. I have a label on my page and I want to bind it to a field in a table. The catch is that I want to bind it to the last row in the table. I think I can use the custom binding, but I don't know how to bind to the last row. Any Suggestions ? p.s. The page is tied to an SqlDataSource that retrieves the data from the above table. Thanks in advance.
Hi, I am using a SQL DataSource with a few parameters. I need to specify the value of the parameters at run time but I need a custom way to do it as the value needs to be calculated not come from Cookie, Control, Form, Profile, QueryString or Session. Is there a way to bind your own value to these parameters. For instance if I had a variable how would I bind that to the parameter? At the moment i am doing the following which works but I dont think it is the correct way dsMyDataSource.SelectParameters["MyParameter"].DefaultValue = MyCalculatedValue; In previous projects i have added a value to the Session and then bound the parameter value to the session but that doesnt seem like a good solution either. Thanks for any help you can give. Martin
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.
I am real new to SQL Server. We are using SQL Server 2000.
My objective is to get a list of all store procedures for specific database. To accomplish this, I programmatically create a connection to the 'master' database where the sp resides, create a callablestatment for 'sp_stored_procedures' ({call sp_stored_procedures(?,?,?)}). I am passing in null, null, and the database name. When I execute the query, I get the below error:
Code:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s). at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
When I made the connection to the master database, I used one of the existing users from the master database.
I looked at the store procedure and verified the sp has 3 input parameter. The first two can be null.
I am not sure why I can not run this sp. I am wondering if we have the database setup properly. Any help or suggestions would be well worth it at this point.
Greetings all,I am a network security professional rather than a MS SQL admin, so Iapologize in advance if this is a bit of a basic question for thislist. I also cross-posted this to microsoft.public.sqlserver.server,so sorry if anyone's read it already.I know an admin setting up a SQL server that will only beaccesible by a webserver running on the same host (not happy aboutrunning private vs publicly avaialable services on the same host , butit's what we've got). As such, I'd like to recommend to him that theSQL server only listen on the localhost ip, 127.0.0.1, thereby makingit inaccesible to the outside world. I looked around the MSknowledgebase but couldn't find a clear document stating how to dothis. Is it even possible? Is there a better option for thisconfiguration?It's been suggested that firewalling is the only option, but I'd reallylike to do *both* (firewall & bind to localhost). The firewall in thiscase will have to be host-based instead (software) instead of hardwarefor non-technical reasons, so additionally if anyone recommends asoftware firewall they use for this purpose I'd appreciate it. My firsimpulse is to recommend Tiny, but I've never used a software firewallfor an MS SQL/Web server before.Thanks,Brian
I'm implementing some database formatting and I need that values withina column have certain limits ... let's say for example, they shouldn'tbe <0 or >10000, but in the case I'm inserting values bigger then 10000I would like that MSSQL "clip" this value to the upper limit (10000 inthis case) and the same with the lower limit (zero in this case).Is that possible? or SQL just respond me with an error when the valuesgo beyond those limits and will abort the transaction?Can someone put some light on this please???Nacho
Hey guys, how can I use a long text as default value in my database (column properties)?I tried to paste my 10 row text into the field but it will only paste the first row as default value.any ideas??
Hello, I just started working with ASP.NET.I'm trying to use the CheckBoxList Control. As I understand it, you can bind a SqlDataSource to this control and it loads the list for you. However tp precheck the items, you have to do this manually. This part works fine. Next part was to save whatever the user checks. I wrote stored Procedure and now just trying to pass 1 parameter to the stored procedure using a second SqlDataSource. I get the error: "A severe error occurred on the current command. The results, if any, should be discarded."Here is the second datasource I am using to try and save the data:<asp:SqlDataSource ID="sds_PersonRole" runat="server" ConnectionString="<%$ ConnectionStrings:Development %>"SelectCommand="usp_selectPersonRole"SelectCommandType="StoredProcedure"UpdateCommand="usp_updatePersonRole"UpdateCommandType="StoredProcedure"><SelectParameters> <asp:ControlParameter ControlID="gv_Person" Name="PERSON_ID" PropertyName="SelectedValue" Type="Int32" /></SelectParameters><UpdateParameters> <asp:Parameter Name="strXML" Size="8000" Type="String" /> <asp:Parameter Direction="InputOutput" Name="err_msg" Type="String" Size="150" DefaultValue="0" /></UpdateParameters></asp:SqlDataSource>I have a code behind file with the following modules: (btnEditPerson is clicked to start the process. the sds_PersonDetails is updated via form contolls and works fine.) Error occurs on the bolded line (Stored procedure is just accepting the string and saving to a field. It works fine, I tested it. Its just erroring out before it runs the stored procedure. Protected Sub btnEditPerson_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEditPerson.Click sds_PersonDetails.Update() gv_Person.DataBind() sds_PersonRole.Update()End Sub Protected Sub sds_PersonRole_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles sds_PersonRole.Updating Dim command As Data.Common.DbCommand command = e.Command 'un-check all checkboxlist items (count - 1 to account for starting at 0) Dim listCount As Integer = cbl_Role.Items.Count() - 1 Dim strXML As String strXML = "<personRole>" For x As Integer = 0 To listCount If cbl_Role.Items(x).Selected() = False Then strXML = strXML & "<person id='" & gv_Person.SelectedValue & "' />" strXML = strXML & "<role id='" & cbl_Role.Items(x).Value & "' />" End If Next strXML = strXML & "</personRole>" command.Parameters("@strXML").Value = strXML lbl_ErrMsg.Text = command.Parameters("@err_msg").Value.ToString() End Sub
I have a SQL database with 1 column in it.. it is a do not call registry for my office. I want to make a web application so our leads can go on the web and request to be put on the do not call list. problem is, if their number already exists, it gets a violation of primary key... Normal handling for this would be to do a select query based on user input, and if it exists in the database, tell them that, else do the insert query... Problem is, i cant seem to figure out how to bind the result of the select query to a textbox or label so i can compare the results to do that logic. Any ideas? This is in asp .net 2.0. Thanks! -Dan
Hello All, I am new to data access and i have got the problem to display the data into the page by binding the gridview with sqlConnection, sqlCommand and sqlDataReader objects. The actually code is written as:protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) {SqlConnection myConnection; SqlCommand myCommand;SqlDataReader myReader; myConnection = new SqlConnection();myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["LatteConnectionString"].ConnectionString; myCommand = new SqlCommand();myCommand.CommandText = "select * from AntiVirusVendors";myCommand.CommandType = CommandType.Text; myCommand.Connection = myConnection; myCommand.Connection.Open();myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); GridView1.DataSource = myReader; GridView1.DataBind(); myCommand.Dispose(); myConnection.Dispose(); }
}
and the GridView in html is listed as: <div> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> So the problem is ---> there is nothing shown in the page, no errors no anything.... just the empty page. Any ideas would be appreciated. Thanks in advance! Joe
hi,i have a DB that contains some tables.so i have a radio button group of tow radio button to display a field.now how can i bind this radio button group to this field for updating and insert a new record?for more explain i brought a little of code below: in .aspx page i have: <asp:RadioButton ID="admin" runat="server" Checked="True" GroupName="membertype" Text="admin" OnCheckedChanged="admin_CheckedChanged" /><br /> <asp:RadioButton ID="member" runat="server" GroupName="membertype" Text="member" /> -------------------------------------------------------------------------- <asp:ControlParameter ControlID="membertype" Name="isadmin" Type="string" PropertyName="text" />-------------------------------------------------------------------------- UpdateCommand="UPDATE UserManagement SET UserName = @UserName, Password = @Password, FullName = @FullName, Description = @Description, UserID = @UserID ,isadmin=@isadmin,usercitycode=@location WHERE (UserID = @Original_UserID)" note that the type of the "isadmin" field is "nvarchar(50)"thanks,M.H.H
Hi All I am trying to bind a gridview to my sql express database through code but my data is not being displayed, i dont get any errors though? If i bind it using an sql datasource it works fine so i know my connection string works and there is data in my database my code is as follows thanks gibbo Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ReadRecords(GridView1, "Select * from Actions") End Sub
Public Shared Function GetConnString() As String Return System.Configuration.ConfigurationManager.ConnectionStrings("actionsConnectionString2").ConnectionString End Function
Private Sub ReadRecords(ByVal datagrid As GridView, ByVal SQL As String) Dim ConnString As String = GetConnString() Dim SqlString As String = SQL Using conn As New SqlClient.SqlConnection(ConnString) Using cmd As New SqlClient.SqlCommand(SqlString, conn) cmd.CommandType = CommandType.Text conn.Open() Using reader As SqlClient.SqlDataReader = cmd.ExecuteReader() datagrid.DataSource = reader datagrid.DataBind() End Using End Using End Using End Sub