How Do You Assign A Data Source To A Page And Which Type Sqldatasource, Objectdatasource Or ?

Mar 5, 2007

Hi

Using ASP.NET 2.0, Sql Server 2005.

I have a simple page (NOT a formview) with some entries textbox's , checkbox and dropdownlistbox's

I want to link a datasource to the 'Item  Page' and bind the datasource's values to the page

The select statement is
Select a.IssueID,
a.ProjectID,
a.VersionID,
a.toincludeversionid,
a.Version,
a.toincludeversion,
a.TypeofEntryID,
a.PriorityID,
a.WorkFlowID,
a.Title,
a.Area,
a.Details,
a.Question,
a.Answer,
a.HowToRepro,
a.DevelopersNotes,
a.TestersNotes,
b.ProjectID,
b.ProjectName,
OldVersion.Version,
ToIncludeVersion.Version,
d.DESCRIPTION,
e.DESCRIPTION,
 
x.TaskID as TaskID,
x.DESCRIPTION as TaskDescription,
z.Taskdone,
CONVERT (char(9),z.TaskAssignedDate, 3) AS Workflowdate,
z.StaffID as StaffID,
w.username,
y.latest_workflowid
from issue as a
Inner join ProjS b on b.ProjectId=a.ProjectID
Left Outer join Version OldVersion on a.VersionID=OldVersion.VersionID
Left Outer join Version ToIncludeVersion on a.VersionID= ToIncludeVersion.VersionID
Inner join TypeOfEntry d on d.TypeOfEntryID=a.TypeofEntryID
Inner join Priority e on e.PriorityID=a.PriorityID
 
inner join workflow z on z.issueid=a.issueid
Inner join (select issueid,max(workflowid) as latest_workflowid from workflow group by issueid) y on y.latest_workflowid=z.workflowid
Inner join task x on  x.taskid=z.taskid
Inner join staffls w on w.StaffID=z.StaffID
 
Where a.IssueID= @IssueID
 
 
I hope I have made query clear, if not I don't mind explaining more.
 
Thanks in advance

 

View 1 Replies


ADVERTISEMENT

AffectedRows Different From ObjectDataSource Then SqlDataSource

May 27, 2008

I have a gridview control that accesses either an objectdatasource or a sqldatasource
both of which excute "select * from customers"
 the affected-rows property when using the sqldatasource is always the number of rows returned (what I want)
but i need to use an object data source to access a table-adapter
when using the ODS affectedrows is always -1 no matter how mayn rows were returned
 why is this
 is there another way to get the number of records returned by an ODS

View 1 Replies View Related

SQLDataSource - How To Filter Out Records That Are In An ObjectDataSource?

Jan 16, 2006

I have an SQLDataSource that I would like to filter out some records that are stored in an ObjectDataSource. Is this possible? The data that is filling the ObjectDataSource is being populated by a WebService.
SQL in SQLDataSource----------------------------
SELECT id, accountFROM contactWHERE id NOT IN (SELECT id FROM ObjectDataSource.Records...)
Thanks.

View 1 Replies View Related

Assign Numeric Data Type To User Variable

Sep 4, 2007



how to pass the column that has a numeric(12,0) data type to user variable in SSIS? what kind of variable data type should I choose?
if i select int64, it keep giving me an error:
Error: 0xC001F009 at Row by Row process: The type of the value being assigned to variable "User:bject_Key" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.

there is no numeric data type in variable..

if you click the drop down box in variable data type, you can only see the below data type:

Int32
int64
Object
Sbyte
single
string
uint32
uint64
boolean
byte
char

View 3 Replies View Related

Sqlbulkcopy Error : The Given Value Of Type SqlDecimal From The Data Source Cannot Be Converted To Type Decimal Of The Specified

Apr 16, 2008

Hi,

The table in SQL has column Availability Decimal (8,8)

Code in c# using sqlbulkcopy trying to insert values like 0.0000, 0.9999, 29.999 into the field Availability
we tried the datatype float , but it is converting values to scientific expressions€¦(eg: 8E-05) and the values displayed in reports are scientifc expressions which is not expected
we need to store values as is


Error:
base {System.SystemException} = {"The given value of type SqlDecimal from the data source cannot be converted to type decimal of the specified target column."}

"System.InvalidOperationException: The given value of type SqlDecimal from the data source cannot be converted to type decimal of the specified target column. ---> System.InvalidOperationException: The given value of type SqlDecimal from the data source cannot be converted to type decimal of the specified target column. ---> System.ArgumentException: Parameter value '1.0000' is out of range.
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlBulkCopy.ConvertValue(Object value, _SqlMetaData metadata)
--- End of inner exception stack trace ---
at System.Data.SqlClient.SqlBulkCopy.ConvertValue(Object value, _SqlMetaData metadata)
at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternal()
at System.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServer(Int32 columnCount)
at System.Data.SqlClient.SqlBulkCopy.WriteToServer(DataTable table, DataRowState rowState)
at System.Data.SqlClient.SqlBulkCopy.WriteToServer(DataTable table)
at MS.Internal.MS
COM.AggregateRealTimeDataToSQL.SqlHelper.InsertDataIntoAppServerAvailPerMinute(String data, String appName, Int32 dateID, Int32 timeID) in C:\VSTS\MXPS Shared Services\RealTimeMonitoring\AggregateRealTimeDataToSQL\SQLHelper.cs:line 269"


Code in C#

SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnection, SqlBulkCopyOptions.Default);
DataRow dr;
DataTable dt = new DataTable();
DataColumn dc;

try
{

dc = dt.Columns.Add("Availability", typeof(decimal));
€¦.

dr["Availability"] = Convert.ToDecimal(s[2]); ------ I tried SqlDecimal
€¦€¦€¦.

}
bulkCopy.DestinationTableName = "dbo.[Tbl_Fact_App_Server_AvailPerMinute]";
bulkCopy.WriteToServer(dt);



thx



View 8 Replies View Related

SqlDataSource.Select Error: Unable To Cast Object Of Type 'System.Data.DataView' To Type 'System.String'.

Oct 19, 2006

I am trying to put the data from a field in my database into a row in a table using the SQLDataSource.Select statement. I am using the following code: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'" myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)But when I run the code, I get the following error:Server Error in '/YorZap' Application. Unable to cast object of type 'System.Data.DataView' to type 'System.String'. 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.InvalidCastException: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.Source Error: Line 54: FileBase.SelectCommand = "SELECT Username FROM Files WHERE Filename = '" & myFileInfo.FullName & "'"
Line 55: 'myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments).GetEnumerator.Current, String)
Line 56: myDataRow("Username") = CType(FileBase.Select(New DataSourceSelectArguments()), String)
Line 57:
Line 58: filesTable.Rows.Add(myDataRow)Source File: D:YorZapdir_list_sort.aspx    Line: 56 Stack Trace: [InvalidCastException: Unable to cast object of type 'System.Data.DataView' to type 'System.String'.]
ASP.dir_list_sort_aspx.BindFileDataToGrid(String strSortField) in D:YorZapdir_list_sort.aspx:56
ASP.dir_list_sort_aspx.Page_Load(Object sender, EventArgs e) in D:YorZapdir_list_sort.aspx:7
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3743
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210 Please help me!

View 3 Replies View Related

How Can I Assign A Stored Procedure As Cursor's Data Source In AStored Procedure?

Oct 8, 2007

How can I create a Cursor into a Stored Procedure, with another Stored Procedure as data source?

Something like this:

CREATE PROCEDURE TestHardDisk
AS
BEGIN

DECLARE CURSOR HardDisk_Cursor
FOR Exec xp_FixedDrives
-- The cursor needs a SELECT Statement and no accepts an Stored Procedure as Data Source

OPEN CURSOR HardDisk_Cursor


FETCH NEXT FROM HardDisk_Cursor
INTO @Drive, @Space

WHILE @@FETCH_STATUS = 0
BEGIN

...
END
END

View 6 Replies View Related

How Do I Get Data Type Of Each Column In A Sqldatasource Control?

Sep 6, 2007

Let's say... the sqldatasource has 3 columns: TableKey(int), TableName(string) and StartDate(datetime) and i'm writing a method to return the data type based on the column name.. for example: GetDataType("StartDate") should return "datetime"...what should i do?

View 2 Replies View Related

How To Assign ConnectionString To A SqlDataSource Within The Namespace?

Apr 16, 2007

hi
i am trying to assign ConnectionString to a SqlDataSource   within the namespace but i am getting this error
plz advise
 
Object reference not set to an instance of an object. 
namespace myNameSpace{   
    public partial class NRP : System.Web.UI.Page    {            SqlDataSource sds1;
        protected void Page_PreInit(object sender, EventArgs e)        {            sds1= new SqlDataSource();            sds1.ID = "sds1";            this.Controls.Add(sds1);
            sds1.ConnectionString = ConfigurationManager.ConnectionStrings["my_conn_str"].ToString();
        }    }}
 

View 1 Replies View Related

Dynamically Assign Select Statement To SqlDataSource

Jan 31, 2008

I wish to dynamically assign Select Statement to SqlDataSource. Anyone has any idea?? Is it possiable at all?
I am coding using C# under Framwork 2.0

View 1 Replies View Related

Dynamically Assign Select Statement To SqlDataSource

Jun 16, 2008

How can i assign select statement to a sqldatasource
I mean if the user clicks button 1
sqldatasource=-"select * from customers where status='ClOSED'  "
or else if the user clicks button2
 sqldatasource="Select * from Customers Where Status='OPEN'  "
 I want to bind the sqldatasource to a gridview finally .
 Is this possible ?
I tried sqldatasource filters  But am reallly confused
Any suggestions/solutions are appreciated
thankyou

View 8 Replies View Related

Data Source Type Not Overwritten When Uploading RDL

Nov 5, 2007



Hello,


I've been working on an application that uploads an RDL to Reporting Services programmatically. I'm having problem with the data source properties for my uploaded report. The datasource for my report is custom datasource. It work s fine if the report still did not exist. But if the report already exist, after I upload the report to Reporting Services, the function will overwrite the RDL but it did not overwrite the Data source type correctly. Other setting like connection string is overwritten correctly.

For example, I already have RDL ABC with Data source type SQL, when I try to overwrite the existing RDL ABC which have Data source type Assembly, it still hold the SQL value for the data source type. But in the RDL itself (I checked in the rdl script in <DataProvider> tag), the value already overwritten to Assembly.

This problem also happen when I try to upload RDL using Report Manager. The Data source type are not overwritten by the action.

What should I do? Why it did not overwrite the datasource type? Maybe I do anything wrong here. I dont know what. Hope someone can help.


Thanks in advance

View 1 Replies View Related

Delete Data From GridView And ObjectDataSource

Mar 11, 2006

The function that is supposed to delete a row, is not working. The function is called, and the windows is refreshed, but the row is not deleted.Can anyone see anything wrong with this code:public static void DeleteBlog(int original_BlogID) { string insertCommand = "DELETE FROM Blog WHERE BlogID = @BlogID"; SqlConnection myConnection = new SqlConnection(Blog.ConnectionString); SqlCommand command = new SqlCommand(insertCommand, myConnection); command.Parameters.Add(new SqlParameter("@BlogID", original_BlogID)); myConnection.Open(); command.ExecuteNonQuery(); myConnection.Close();}

View 3 Replies View Related

Excel Source From Variables And Data Type Issue

Aug 22, 2007

Hi

I am after some help with the following issue

I have a package that reads a table for a file path of a excel file. This gets passed to a variable and then this file is imported into a staging table for further transformation work. The issue i have is that file 1 may contain data in Column A which is 50 characters long in which case i have to import the excel as a DT_WSTR, do a data conversion to a DT_STR and load to the staging table. However file 2 may contain data in Column which is over 255 characters in which case it would import as a DT_NTEXT which i then transform to a DT_TEXT and then to a DT_STR. I used a fixed file path in the Excel Connection to start with which was for File 1 so the datatype for column 1 is a DT_WSTR. I then changed the excel connection to a filepath variable, put the path of file 2 in my table and called it from my package. It failed as the data exceeding 255 characters in column 1 needed to be a DT_NTEXT. I can change it and it works but if i then run the package using file 1 (less than 255 characters) it fails again as it wants it to be a DT_WSTR.

Is there anyway around this? Am i missing something as i would have thought that by setting it to DT_NTEXT this would cover data under 255 characters as well.

Any help is gratefully aprreciated.

View 6 Replies View Related

Code Page Translations Are Not Supported For The Text Data Type. From: 1252 To: 950.

Jul 23, 2005

Code page translations are not supported for the text data type. From:1252 To: 950.I would like to know what this message means. I also installed thelanguage packs in advanced settings, Everything is set to English. Mywindows XP computer is XP English. For some reason I cant get an updateto go thru using ADO. like Recordset.UpdateAlthough other routines using .update workAny ideas?

View 6 Replies View Related

Assign Variable For FileName Of Source File

Aug 10, 2006

I am wanting to capture the file name I am using to load data from and use it in a SQL statement to insert it along with the data that I load.

I am using a ForEach container to load all my .txt files but cannot figure out how to capture the name of each source file as it loops through the files and then add it to my insert statement that is populating my history table. I would think that the ForEach container has that information, but I do not see how to access it and assign it to a variable that I could use in my SQL statement.

Any ideas or suggestions?

View 4 Replies View Related

Why Cant I Set The Precision For Decimal Data Type In SSIS Flat File Source?

Mar 2, 2007

I have a CSV Flat File Source with a Decimal column - but DataPrecision property is grayed out - why?

View 1 Replies View Related

XML Source Produces DT_UI8 Key Columns - Which SQL Server Data Type To Store?

Aug 12, 2007

I'm using the XML Source to process a hierarchical set of XML. As such, the XML Source creates keys to maintain the hierarchy. This is very convenient, and keeps me from having to invent my own keys.

The problem is that the datatype of these keys defaults to DT_UI8. Which SQL Server 2005 datatype should I use to store these values in my staging tables? BIGINT corresponds to DT_I8, which can't accept DT_UI8 values.

View 8 Replies View Related

Can't Assign Connection Manager Object To DataReader Source

Sep 22, 2006



I'm trying to create a DataReader source object using a working ADO.NET Oracle Client connection object that exists in the connection manager.

Problem:

When I open the editor the DataReaderSrc component shows only one row under the Connection Managers tab:

Name=IDbConnection
Connection Manager=blank
Description=Managed connection manager

I cannot assign the ADO.NET connection (or any connections). I see a warning at the bottom of the Connection Managers tab:

"Not all connection managers have been set. Set all connection managers."

When I click refresh the warning message changes to:

"The runtime connection manager with the ID "" cannot be found. Verify that the connection manager collection has a connection manager with that ID."

I am prevented from removing the IDbConnection or assigning my Connection Manager object to the DataReader Source.


Thanks, -- Mike

View 9 Replies View Related

Can't Insert New Data To Sql Using Sqldatasource.insert, Web Forms And A Master Page

Sep 11, 2006

Hello, I'm new to the forum and new to SQL, ASP.NET, etc.  I am creating an intranet site for my company in VS 2005 and have run into a very annoying problem that I can't seem to solve.  I have tried Googling it and came up empty.  I have a database in SQL Express 2005 and my website will be accessing several tables within the database.  I can retrieve info just fine and I can update, delete, etc just fine using gridview or other prebuilt tools, but when I add a few text boxes and wire a button to the SqlDataSource.Insert() command, I get a new record that is full of null values except for the identity key I have set.  The kicker is that I am also using a master page and when I duplicate the web page without the master page link, everything works just fine.  The following snippets show what I'm doing:<InsertParameters><asp:FormParameter Name="Name" Type="String" FormField="txtName" /><asp:FormParameter Name="Location" Type="String" FormField="ddlLocation" /><asp:FormParameter Name="Issue" Type="String" FormField="txtProblem" /></InsertParameters>Of course I match the formfields to the text boxes, create an onclick event for my button, the sqldatasource is configured correctly, it just doesn't work with the master page no matter what I do. Any help would be appreciated. Thanks

View 3 Replies View Related

I Need To Pass Data Entered /created On The First Page To The Next Page And Populate The Next Page With Some Data From The Fir

Nov 28, 2006

Hello I have a project that uses a large number of MS Data access pages created in Access 2003 and runs on MS SQL2005.

When I am on lets say my client, (first page in a series) data access page and I have completed the fields in the (DAP), I am directing my users to the next step of the registration process by means of a hyperlink to another Data access page in the same web but in a linked or sometimes different table.


I need to pass data entered /created on the first page to the next page and populate the next page with some data from the first page / table. (like staying on the client name and ID when i go to the next page)


I also need the first data access page to open and display a blank or new record. Not an existing record. I will also be looking to creata a drop down box as a record selector.


Any pointers in the right direction would be appreciated.
I am some what new to data access pages so a walk through would be nice but anything you got is welcome. Thanks Peter€¦

View 2 Replies View Related

Assign New Value Of ReadWrite Column Of String Type In Script Component?

Jul 23, 2007

I am new user on VB ( I wish ssis support c# script)



I have made a input string type column ( strName ) in script componen as ReadWrite.



In my script, I did following:



Row.strName = Row.strName + prefix



But I got following error at runtime:



The value is too large to fit in the column data area of the buffer.



at Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer.SetString(Int32 columnIndex, String value)

at Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer.set_Item(Int32 columnIndex, Object value)

at Microsoft.SqlServer.Dts.Pipeline.ScriptBuffer.set_Item(Int32 ColumnIndex, Object value)

at ScriptComponent_98d10a05854c460792443f2345d5d806.Input0Buffer.set_strName(String Value)

at ScriptComponent_98d10a05854c460792443f2345d5d806.ScriptMain.Input0_ProcessInputRow(Input0Buffer Row)

at ScriptComponent_98d10a05854c460792443f2345d5d806.UserComponent.Input0_ProcessInput(Input0Buffer Buffer)

at ScriptComponent_98d10a05854c460792443f2345d5d806.UserComponent.ProcessInput(Int32 InputID, PipelineBuffer Buffer)

at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.ProcessInput(Int32 inputID, PipelineBuffer buffer)





Could anyone tell me what I did wrong?



Thanks!

View 8 Replies View Related

SqlDataSource - Where To Put It ? On The Page - In The Code Behind ?

Nov 19, 2006

Hi,
I have the following Sql Data Source that I wish to bring back on my page:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FrogConnectionString %>"
SelectCommand="ProposalsCheckNewCustomerData" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:FormParameter FormField="MaritalStatusID" Name="MartialStatusID" Type="Int32" />
<asp:FormParameter FormField="LivingStatusID" Name="LivingStatusID" Type="Int32" />
<asp:FormParameter FormField="DealerID" Name="DealerID" Type="Int32" />
<asp:FormParameter FormField="VehicleTypeID" Name="VehicleTypeID" Type="Int32" />
<asp:FormParameter FormField="FinanceTypeID" Name="FinanceTypeID" Type="Int32" />
<asp:FormParameter FormField="MediaSourceID" Name="MediaSourceID" Type="Int32" />
<asp:FormParameter FormField="DealerContactID" Name="DealerContactID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
The recordset brings back 7 values that I wish to populate into 7 Labels.
1. Should the SqlDataSource be on the page (between the Head tags) or within the Page_Load command of the Page Behind ?- If its on the page behind do any of you have any sample code to show me how to get the recordset up and running ?
2. How would I bind the results to a label ?- Within my old asp pages it was simple (I'm not saying its not simple here, I am still getting my head around vb.net)- eg <%=rsX("MaritalStatus")%> I guess its something very similar
Thanks for any pointersFizzystutter
 

View 4 Replies View Related

Multiple SqlDataSource On A Page

Nov 26, 2006

Hi,
I placed several SqlDataSource objects on my page which work with the same database (same connection string).
As I know, connection operation to database is costly in the performance prespective. 
Do these SqlDataSource controls work with the same connection object or each of them create his own connecton object?
If each create it's own, then can they be changed to work with one connection object?
 
Thanks
 

View 3 Replies View Related

An Error Has Occurred During Report Processing. A Data Source Instance Has Not Been Supplied For The Data Source DetailDS_get_o

Mar 13, 2008

hi ,

i am trying for a drill through report (rdlc)

ihave written the following code in drill through event of reportviewer, whenever i click on the first report iam getting the error like

An error has occurred during report processing.


A data source instance has no
t been supplied for the data source "DetailDS_get_orderdetail".







the code is



using System;

using System.Data;

using System.Data.SqlClient;

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 Microsoft.ApplicationBlocks.Data;

using Microsoft.Reporting.WebForms;

using DAC;

public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

ReportViewer1.Visible = false;

}

protected void Button1_Click(object sender, EventArgs e)

{

DAC.clsReportsWoman obj = new clsReportsWoman();

DataSet ds = new DataSet();

ds = obj.get_order();

ReportViewer1.LocalReport.DataSources.Clear();

ReportDataSource reds = new ReportDataSource("DataSet1_get_order", ds.Tables[0]);



ReportViewer1.LocalReport.DataSources.Add(reds);

ReportViewer1.LocalReport.ReportPath = "C:/Documents and Settings/km63096/My Documents/Visual Studio 2005/WebSites/drillthrurep/Report.rdlc";

ReportViewer1.LocalReport.Refresh();

ReportViewer1.Visible = true;

}

protected void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)

{

DAC.clsReportsWoman obj = new clsReportsWoman();

ReportParameterInfoCollection DrillThroughValues =

e.Report.GetParameters();



foreach (ReportParameterInfo d in DrillThroughValues)

{

Label1.Text = d.Values[0].ToString().Trim();

}

LocalReport localreport = (LocalReport)e.Report;

string order_id = Label1.Text;

DataSet ds = new DataSet();

ds = obj.get_orderdetail(order_id);



ReportViewer1.LocalReport.DataSources.Clear();

ReportDataSource reds = new ReportDataSource("DetailDS_get_orderdetail", ds.Tables[0]);

ReportViewer1.LocalReport.DataSources.Add(reds);

ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"Reportlevel1.rdlc");

ReportViewer1.LocalReport.Refresh();





}



}

the code in method get_orderdetail(order_id) is

public DataSet get_orderdetail(string order_id)
{
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
cmd.Parameters.Add("@order_id", SqlDbType.VarChar, 50);
cmd.Parameters["@order_id"].Value = order_id;
ds = SQLHelper.ExecuteAdapter(cmd, CommandType.StoredProcedure, "dbo.get_orderdetail");
return (ds);
}pls help me.

View 1 Replies View Related

SQLDataSource No Bind On Page Load?

Aug 29, 2006

I use SQLDataSource, bind to a GridView and a SelectParameter that gets it's value from a textbox.  If the textbox is empty, then it returns all rows.How do I prevent the query and binding when the page first load?  Thanks

View 11 Replies View Related

Multiple SqlDataSource Controls On A Page

Jun 8, 2007

Thanks for your help.
 I'm just getting into ASP.NET 2.0 and started using the SqlDataSource control to declaritively connect to a database. I was wondering if I have two SqlDataSource controls on one page with two select commands querying the same database, will the that create to seperate instances of opening and closing the connection to the database, or will it open the database once, execute both queries, and then close the connection. It seems that if it creates two separate connections, it would still be more efficient to to connect to the database programmatically using ADO.NET. You would only need to make one trip to the database, pull down all of your data, and then close the connection.
Adrian

View 1 Replies View Related

Index Creation Causes Error The Conversion Of A Char Data Type To A Datetime Data Type Resulted...

Jul 23, 2005

Hi all,I have a table called PTRANS with few columns (see create script below).I have created a view on top that this table VwTransaction (See below)I can now run this query without a problem:select * from dbo.VwTransactionwhereAssetNumber = '101001' andTransactionDate <= '7/1/2003'But when I create an index on the PTRANS table using the command below:CREATE INDEX IDX_PTRANS_CHL# ON PTRANS(CHL#)The same query that ran fine before, fails with the error:Server: Msg 242, Level 16, State 3, Line 1The conversion of a char data type to a datetime data type resulted inan out-of-range datetime value.I can run the same query by commeting out the AssetNumber clause and itworks fine. I can also run the query commenting out the TransactionDatecolumn and it works fine. But when I have both the conditions in theWHERE clause, it gives me this error. Dropping the index solves theproblem.Can anyone tell me why an index would cause a query to fail?Thanks a lot in advance,AmirCREATE TABLE [PTRANS] ([CHL#] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,[CHCENT] [numeric](2, 0) NOT NULL ,[CHYYMM] [numeric](4, 0) NOT NULL ,[CHDAY] [numeric](2, 0) NOT NULL ,[CHTC] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL) ON [PRIMARY]GOCREATE VIEW dbo.vwTransactionsASSELECT CONVERT(datetime, dbo.udf_AddDashes(REPLICATE('0', 2 -LEN(CHCENT)) + CONVERT(varchar, CHCENT) + REPLICATE('0', 4 -LEN(CHYYMM))+ CONVERT(varchar, CHYYMM) + REPLICATE('0', 2 -LEN(CHDAY)) + CONVERT(varchar, CHDAY)), 20) AS TransactionDate,CHL# AS AssetNumber,CHTC AS TransactionCodeFROM dbo.PTRANSWHERE (CHCENT <> 0) AND (CHTC <> 'RA')*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 1 Replies View Related

How Do I Pass A Parameter To A Sqldatasource In A Code Behind Page

Feb 1, 2007

i have a sqldatasource on my asp.net page -- select * from table where id = @id
i want to set the @id in the backend and set the result to textbox1.text
how do i do this?

View 1 Replies View Related

SqlDataSource Control And Master Page Problem - Please Help

Feb 17, 2006

1. Create a new .aspx page and add this inside the form tag:    <div>        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>        <asp:Button ID="Button1" runat="server" Text="Button" />        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"            SelectCommand="SELECT * FROM [Comments]" InsertCommand="INSERT INTO Comments(CommentAuthor, CommentText) VALUES (@auth, @text)">            <InsertParameters>                <asp:FormParameter FormField="TextBox1" Name="auth" />                <asp:FormParameter FormField="TextBox2" Name="text" />            </InsertParameters>        </asp:SqlDataSource>        </div>2. Add the event handler for the button in code behind:    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Me.SqlDataSource1.Insert()    End Sub3. Run the page, enter some text into the textboxes and hit the button. GREAT! The data was successfully inserted into the database.Now, let's try the exact same thing, but this time lets create a Master Page first. So:1. Create a new master page.2. Create a new .aspx page, check the 'select master page' checkbox and then select the newly created master page.3. Add the exact same as above in between the asp:Content begin and end tags:    <div>        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>        <asp:Button ID="Button1" runat="server" Text="Button" />        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"            SelectCommand="SELECT * FROM [Comments]" InsertCommand="INSERT INTO Comments(CommentAuthor, CommentText) VALUES (@auth, @text)">            <InsertParameters>                <asp:FormParameter FormField="TextBox1" Name="auth" />                <asp:FormParameter FormField="TextBox2" Name="text" />            </InsertParameters>        </asp:SqlDataSource>        </div>4. Add the event handler for the button in code behind.    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        Me.SqlDataSource1.Insert()    End Sub5. Run the page, enter some text into the textboxes and hit the button. WHOOT!? This time it doesn't work and the following error appears:Cannot insert the value NULL into column 'CommentAuthor', table 'C:DOCUMENTS AND SETTINGSSONYMY DOCUMENTSVISUAL STUDIO 2005WEBSITESCOMMENTSAPP_DATACOMMENTS_DB.MDF.dbo.Comments'; column does not allow nulls. INSERT fails.The statement has been terminated. 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: Cannot insert the value NULL into column 'CommentAuthor', table 'C:DOCUMENTS AND SETTINGSSONYMY DOCUMENTSVISUAL STUDIO 2005WEBSITESCOMMENTSAPP_DATACOMMENTS_DB.MDF.dbo.Comments'; column does not allow nulls. INSERT fails.The statement has been terminated.Source Error: Line 4:  Line 5:      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.ClickLine 6:          Me.SqlDataSource1.Insert()Line 7:      End SubLine 8:  End Class Source File: C:Documents and SettingsSONYMy DocumentsVisual Studio 2005WebSitesComments2.aspx.vb    Line: 6 So can anyone explain why this only works in the first example?Many thanks,

View 4 Replies View Related

SQLDataSource - Using The Latest Index From An Insert Elsewhere On A Page

May 22, 2006

I have a page that has a drop down control that is used to control the items in a FormView.  The drop down is bound to one SQLDatasource while the FormView is bound to another SQLDataSource.  I've got everything working great.  Selecting an item in the drop down reveals the details in the form view.  the Form can be opened for editing and deleting.  I even have the Insert working.  But there lies my problem.  Once the Insert is executed I'd like to take the Index value of the recently submitted item and set it to the SelectedIndex of my dropdown.  Here is the code for each of the SQL events  Sub FormViewUpdated(ByVal sender As Object, ByVal e As FormViewUpdatedEventArgs) Handles FormView1.ItemUpdated
confirmation.Visible = True
confirmation.Text = "<img src=""../img/smiley36.gif"">&nbsp;Your record has been updated."

Dim index As Integer = Me.DropDownList1.SelectedIndex
DropDownList1.DataBind()
Me.DropDownList1.SelectedIndex = index
End Sub


Sub FormViewDeleted(ByVal sender As Object, ByVal e As FormViewDeletedEventArgs) Handles FormView1.ItemDeleted
confirmation.Visible = True
confirmation.Text = "<img src=""../img/smiley36.gif"">&nbsp;Your record has been deleted."

DropDownList1.DataBind()
FormView1.ChangeMode(FormViewMode.ReadOnly)
End Sub

Sub FormViewInserted(ByVal sender As Object, ByVal e As FormViewInsertedEventArgs) Handles FormView1.ItemInserted
confirmation.Visible = True
confirmation.Text = "<img src=""../img/smiley36.gif"">&nbsp;Your record has been inserted."
DropDownList1.DataBind()
End Sub
 I would like to do something similar to the Updated event in the Inserted sub.  Notice I have a Me.DropDownList.SelectedIndex bit...I'd like to be able to set a variable to the new ID and then set the Me.DropDownList.SelectedIndex to that variable.  My stored proc for the Insert reads like
  ALTER PROCEDURE dbo.usp_INSERTHelp_Faq
(
@FAQQuestion varchar(500),
@FAQText ntext,
@FAQIndex varchar(500),
@ModifiedBy int,
@Help_FAQID int OUTPUT
)
AS
INSERT INTO Help_FAQ (FAQQuestion, FAQText, FAQIndex,ModifiedBy, Views)
VALUES (@FAQQuestion,@FAQText,@FAQIndex,@ModifiedBy,0)

SELECT @Help_FaqID = @@Identity
RETURN
 So, the Stored Proc is set up to return the latest ID.  Also, my SQLDataSource for the FormView has an InsertParameter:  <asp:Parameter Direction="Output" Name="Help_FAQID" Type="Int32" />
 
Any thoughts on how to close the loop here?  How do I get my hands on the new Help_FAQID?

View 3 Replies View Related

System.Data.SqlClient.SqlException: The Conversion Of A Char Data Type To A Datetime Data Type Resulted In An Out-of-range Datetime Value.

Dec 14, 2005

After testing out the application i write on the local pc. I deploy it to the webserver to test it out. I get this error.

System.Data.SqlClient.SqlException: The conversion of a char data type to a
datetime data type resulted in an out-of-range datetime value.

Notes: all pages that have this error either has a repeater or datagrid which load data when page loading.

At first I thought the problem is with the date, but then I can see
that some other pages that has datagrid ( that has a date field) work
just fine.

anyone having this problem before?? hopefully you guys can help.

Thanks,

View 4 Replies View Related

Converting A Data Type Double To A Type Float Using A Data Adapter &&amp; SSCE 3.5

Feb 13, 2008

Hi,

I can populate a dataTable with type double (C#) of say '1055.01' however when I save these to the CE3.5 database using a float(CE3.5) I lose the decimal portion. The 'offending' code is:


this.court0TableAdapter1.Update(this.mycourtsDataSet1.Court0);

this.mycourtsDataSet1.AcceptChanges();

this.court0TableAdapter1.Fill(this.mycourtsDataSet1.Court0);


This did not happen with VS2005/CE3.01.

I have tried changing all references to decimal (or money in CE3.5) without luck.

I'm beginning to think that string may be the way to go!!!!!!!

Can someone shed some light on my problem.

Thanks,

Later:

It's necessary to update the datatable adapter as the 3.01 and 3.5 CE are not compatible.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved