NULL As Defaultvalue In Select Command

Feb 13, 2007

Hello everybody,

I have following datasource

  <asp:SqlDataSource ID="sqlIncidentTemplates" runat="server" ConnectionString="<%$ ConnectionStrings:Standard %>"
SelectCommand="SELECT [IncidentText] FROM [IncidentTemplates] WHERE [ConstrAreaID] = @ConstrAreaID AND [ConstrDeviceID] = @ConstrDeviceID">
<SelectParameters>
<asp:Parameter DefaultValue="" Name="ConstrAreaID" Type="Int32" ConvertEmptyStringToNull="true" />
<asp:Parameter DefaultValue="" Name="ConstrDeviceID" Type="int32" ConvertEmptyStringToNull="true" />
</SelectParameters>

 As far as I understand default select command should be "SELECT IncidentText FROM IncidentTemplates WHERE ConstrAreaID IS NULL AND ConstrDeviceID IS NULL". Unfortunately this is not the case. I assume that the "[ConstrAreaID] = @ConstrAreaID " is translated into "ConstrAreaID = NULL".

Could this be the reason and how can I solve this problem?

Thanks in advance

View 3 Replies


ADVERTISEMENT

Defining Command,commandtype And Connectionstring For SELECT Command Is Not Similar To INSERT And UPDATE

Feb 23, 2007

i am using visual web developer 2005 and SQL 2005 with VB as the code behindi am using INSERT command like this        Dim test As New SqlDataSource()        test.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString1").ToString()        test.InsertCommandType = SqlDataSourceCommandType.Text        test.InsertCommand = "INSERT INTO try (roll,name, age, email) VALUES (@roll,@name, @age, @email) "                  test.InsertParameters.Add("roll", TextBox1.Text)        test.InsertParameters.Add("name", TextBox2.Text)        test.InsertParameters.Add("age", TextBox3.Text)        test.InsertParameters.Add("email", TextBox4.Text)        test.Insert() i am using UPDATE command like this        Dim test As New SqlDataSource()        test.ConnectionString = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ToString()        test.UpdateCommandType = SqlDataSourceCommandType.Text        test.UpdateCommand = "UPDATE try SET name = '" + myname + "' , age = '" + myage + "' , email = '" + myemail + "' WHERE roll                                                         123 "        test.Update()but i have to use the SELECT command like this which is completely different from INSERT and  UPDATE commands   Dim tblData As New Data.DataTable()         Dim conn As New Data.SqlClient.SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated                                                                                Security=True;User Instance=True")   Dim Command As New Data.SqlClient.SqlCommand("SELECT * FROM try WHERE age = '100' ", conn)   Dim da As New Data.SqlClient.SqlDataAdapter(Command)   da.Fill(tblData)   conn.Close()                   TextBox4.Text = tblData.Rows(1).Item("name").ToString()        TextBox5.Text = tblData.Rows(1).Item("age").ToString()        TextBox6.Text = tblData.Rows(1).Item("email").ToString()       for INSERT and UPDATE commands defining the command,commandtype and connectionstring is samebut for the SELECT command it is completely different. why ?can i define the command,commandtype and connectionstring for SELECT command similar to INSERT and UPDATE ?if its possible how to do ?please help me

View 2 Replies View Related

Specifying DefaultValue But Not Showing Up After Deployment.

Feb 6, 2007

Hi,

For some reason when I deploy the report to ReportServer, the <DefaultValue> is not showing up. It does show up on the Preview though.

I have 3 parameters: Start Date, End Date, Status.

I'd like the default to be the first value: 1 (Issued)

Here is the XML:

<ReportParameters>
<ReportParameter Name="StartDate">
<DataType>DateTime</DataType>
<Prompt>Start Date:</Prompt>
</ReportParameter>
<ReportParameter Name="EndDate">
<DataType>DateTime</DataType>
<Prompt>End Date:</Prompt>
</ReportParameter>
<ReportParameter Name="Status">
<DataType>String</DataType>
<Prompt>Status:</Prompt>
<DefaultValue>
<Values>
<Value>1</Value>
</Values>
</DefaultValue>
<ValidValues>
<ParameterValues>
<ParameterValue>
<Value>1</Value>
<Label>Issued</Label>
</ParameterValue>
<ParameterValue>
<Value>2</Value>
<Label>Voided</Label>
</ParameterValue>
<ParameterValue>
<Value>3</Value>
<Label>Issued and Voided</Label>
</ParameterValue>
</ParameterValues>
</ValidValues>
</ReportParameter>
</ReportParameters>

I'm not sure why the changes are not being deployed.

Any help would greatly be appreciated.

Thanks.

View 1 Replies View Related

Inserting The Date As Defaultvalue In A Sqldatasource Parameter

Sep 21, 2006

Hi Guys. I am trying to insert the date as the default value into the DatePosted parameter in the sqldatasource object. I have put have the following below but it doesn't work. I have also tried  <asp:Parameter Name="DatePosted" Type="DateTime" DefaultValue="<%= Date.Now %>" /> <asp:Parameter Name="DatePosted" Type="DateTime" DefaultValue="<%= now() %>" /> I know the solution is probably simple and I look like an idiot, but excuse me because I am very knew and fragile at this lol... any help would be great :). Mike. 

View 7 Replies View Related

Insert Command Does Not Like Null Values.

Jan 5, 2004

- I'm a Novice -

I'd like to use an insert command to insert whatever data that is on the unbound form. The first three fields are required and I check those values prior to executing the code below. But some fields may be null.

Dim strSQL as string
.
.
code
.
.
strSQL = "INSERT INTO tblCase " & _
"(Case_SiteName, " & _
"Case_PatientSequenceNumber, " & _
"Case_PatientInitials, " & _
"Case_DOB, " & _
"Case_ProcedureDate, " & _
"Case_Investigator, " & _
"Case_Institution, " & _
"Case_Value) " & _
"VALUES ('" & Me.cboSiteName & "', " & _
Me.txtPatientNumber & ", '" & _
Me.tbxPatientInitials & "', '" & _
Me.tbxPatientDOB & "', '" & _
Me.tbxProcDate & "', '" & _
Me.tbxInvestigator & "', '" & _
Me.tbxInstitution & "', " & _
Me.grpValue & ");"

CurrentProject.Connection.Execute strSQL

But, when any of the last four are unanswered, i get an error. Any, or all of the last four can be blank. Any suggestions?

View 14 Replies View Related

Command.ExecuteNonQuery() Error Occurring NULL Value

Apr 2, 2008

Here is the table that I am wanting to insert the information into (BTW I am wanting the UserID, EntryDate, Note) On my page i do have a text box for the UserID as well as a Note textbox. When I hite the submit button on my page I am already sending the UserID textbox information to be sent to another table (called RequestTable). However, I am wanting to take that same UserID and insert it into the RequestNote table as well. Let me know if you have any questions for me to further explain anything.
**RequestNote**RequestNoteKey (PK)  (has identity set to yes)RequestKey (allows nulls)NoteEntryDateEntryUserID  (allows Nulls)****This is my stored procedure that I am calling called "NoteInsert"***@Note nvarchar(1000),@EntryUserID nvarchar(50)AS INSERT INTO RequestNote (Note, EntryDate,EntryUserID)
VALUES (@Note,GetDate(), @EntryUserID)
RETURNGO
****THIS IS THE PAGE THAT CONNECTS THE USER INTERFACE AND STORED PROCEDURE***public static void AddRequestNote(string requestNote, string userID){using (SqlConnection connection = new SqlConnection(connRequestNote)){using (SqlCommand command = new SqlCommand("NoteInsert", connection)){command.CommandType = CommandType.StoredProcedure;command.Parameters.Add(new SqlParameter("@Note", requestNote));command.Parameters.Add(new SqlParameter("@EntryUserID", userID));connection.Open();command.ExecuteNonQuery(); <--THIS IS WHERE I GET AN ERROR THAT SAYS Cannot insert the value NULL into column 'RequestNoteKey', table 'RequestNote'; column does not allow nulls. INSERT fails}

View 5 Replies View Related

NULL Values In A SELECT In Another SELECT

Jan 23, 2008

Hi,I have a query like this :SELECTx1,x2,( SELECT ... FROM ... WHERE ...UNIONSELECT ... FROM ... WHERE ...) as x3FROM ...WHERE ...The problem is that I don't want to return the results where x3 isNULL.Writing :SELECTx1,x2,( SELECT ... FROM ... WHERE ...UNIONSELECT ... FROM ... WHERE ...) as x3FROM ...WHERE ... AND x3 IS NOT NULLdoesn't work.The only solution I found is to write :SELECT * FROM((SELECTx1,x2,( SELECT ... FROM ... WHERE ...UNIONSELECT ... FROM ... WHERE ...) as x3FROM ...WHERE ...) AS R1)WHERE R1.x3 IS NOT NULLIs there a better solution? Can I use an EXISTS clause somewhere totest if x3 is null without having to have a 3rd SELECT statement?There's probably a very simple solution to do this, but I didn't findit.Thanks

View 7 Replies View Related

[F4] Properties Dialog Does Not Follow Convention Of Defaultvalue &&<&&> Bold, Changedvalue=bold

Sep 7, 2007

Just thought I'd point it out as something that needs fixing. This is inconsistent with every other MS product using the VS.net IDE framework.

I'd post it on Connect but then I'd wait 2 months to get "won't fix - this does not 'fit' with the current Katmai schedule" i.e. if I'm lucky (based on the new improved 3yr delivery of sql) it might get delivered in 2011. Wow.

Imagine if Xbox or PS3 designers told their customers, "sorry we know that up/down/left/right are in fact right/left/down/up, as you may expect on a game controller, but if you wait 3 years we might fix it"

View 3 Replies View Related

Select Command

Oct 9, 2006

I'm using the following Select Command:SELECT MAX(Document) AS DOC FROM dbo.Communicator WHERE (ReleaseDate <= { fn NOW() })It shows the most current date in the ReleaseDate column - even if the date is in the future. I don't want it to show future dates. If I change the command to WHERE (ReleaseDate >= { fn NOW() }) it doesn't work at all. I only want it to return one row - the latest releases date that is equal to or less than now.Any ideas?

View 3 Replies View Related

SQL Select Command

May 29, 2007

I have a web form that has textbox1, textbox2 and DropDownList1.  Let’s say textbox one is first name, textbox2 is last name and dropdownlist1 is age. How do I write a query that will select from database table dbo.emoployee where last name = dbo.employee.lastname and all other fields are blank, I want it to return all employees with that last name. If someone types in the last name and selects the age from the drop down list then I want to return all employees where last name = dbo.employee.lastname and age = dbo.employee.age. If someone types in just the first name then I want to return all employees where first name = pub.employees.firstname? I have been trying to do this using the SQLDatasource but cannot seem to figure it out.

View 5 Replies View Related

SQL Select Command

May 29, 2007

I have a web form that has textbox1, textbox2 and DropDownList1.  Let’s say textbox one is first name, textbox2 is last name and dropdownlist1 is age. How do I write a query that will select from database table dbo.emoployee where last name = dbo.employee.lastname and all other fields are blank, I want it to return all employees with that last name. If someone types in the last name and selects the age from the drop down list then I want to return all employees where last name = dbo.employee.lastname and age = dbo.employee.age. If someone types in just the first name then I want to return all employees where first name = pub.employees.firstname? I have been trying to do this using the SQLDatasource but cannot seem to figure it out.

View 3 Replies View Related

Ms Sql Select Command

Jan 11, 2008

I currently have a webpage that allows visitors to post links to their own website.  As a spam filter I want to create a scheduled task that selects repeat entries in the database under the column name domain.  I already made a filter to take everything out of the link the provide and leave it with just the domain name.  I tested it and it works.  Now I need a SQL command to select all the rows with repeats of the domain.  Look at the following table example to better understand what I mean uid            x            y           domain1             100        110          www.spam.com2             100         120        www.spam.com3             110         130         www.homepage.com4             210         220        www.myaspspam.com5             510          560       www.myaspspam.com  in this example I would like 1 and 2 to be selected as well as 4 and 5 into a dataadapter so that I can delete them accordingly. 

View 2 Replies View Related

Need Help With This Select Command

Jan 28, 2008

 im trying to write a select command that gets info from 1 table and counts 11 differnt things in it im not sure if this is even posiable but if it is could someone help  this is what i got for counting all of them SELECT owner, COUNT(*) AS TotalPots
FROM Items
WHERE (Name = 'Holy Potion') OR
(Name = N'Arcane Potion') OR
(Name = N'Shadow Potion') OR
(Name = N'Fire Potion') OR
(Name = N'Kinetic Potion') OR
(Name = N'Potion of Holy Resistance') OR
(Name = N'Potion of Arcane Resistance') OR
(Name = N'Potion of Shodow Resistance') OR
(Name = N'Potion of Fire Resistance') OR
(Name = N'Potion of Kinetic Resistance')
GROUP BY owner
ORDER BY COUNT(*) DESC  the 11 coloums i want are Holy, Arcane, Shadow, Fire, Kinetic, Holy Resist, Arcane Resist, Shadow resist, Fire Resist, Kinetic Resist, And Total Pots Also would like it on my Asp.net page at the bottom of the grid view to have a total row that counts all the colums up 

View 8 Replies View Related

Sql Select Command

Aug 18, 2006

Hello,everyone,i have a problem:(about BOM caculation)

The BOM is B--87700

has one outside service,and two children parts:z--877,and s--877

i have a table,this table which contains columns like this:

part_id description price(unit price) quatity

B--877 FD 82.36$(service price) 1

Z--877 Roughcast 2.36$ 4

S--877 the same 8.36$ 12

and i want to get a result of this:

part_id description price

B--877 FD (82.36+2.36*4+8.36*12)=192.12(just the result 192.12 is okay)

how can i achieve this target?

View 3 Replies View Related

OLE DB Command And Select

Sep 21, 2007

I am trying to run a select command on an OLE DB Command transform such as:

Select * from table where id = ?

I have the mapping to the parameter working and the command is working but how to map the select output to columns when you can't create output columns on the OLE DB Command?

Is this the correct transform to use?

Thanks

View 3 Replies View Related

OLE DB Command And Select

Dec 20, 2007

Thanks for this help. My problem is a little different. I have a stored procedure with an output parameter that I want to use in an OLE DB transform. I can see how to add output columns but can't figure out how to set them from the stored procedure return. Any ideas?

View 1 Replies View Related

ASP: SqlDataSource - Select Command

Aug 10, 2007

I am using  <asp:SqlDataSource ID and for the Select Command, the following, where the WHERE clause ... for an exact match (=) works correctly:
SelectCommand="SELECT [PatientID], [MedRecord] , [Accession], [FirstName], [LastName], [Address1] FROM [ClinicalPatient] WHERE (LastName = @LastName) ORDER BY [LastName]DESC">
 I would like to do a "LIKE" search where the LastName Parameter is matched using "LIKE".  In  this situation how would the syntax be written.... I tried:
LastName LIKE '%" & LastName & "%'"
But I get an error???? Any suggestions, please...
Thanks !!

View 4 Replies View Related

SqlDataSource Select Command

Nov 15, 2007

I have a SqlDataSource object that is bound to a GridView control. I have configured the SqlDataSource with a default select command. Under certain values of query strings on the URL for this page (Default.aspx), I want to change the select command. So I put the statements in the Page_Load method for Default.aspx to define SqlDataSource1.SelectCommand. The changed SelectCommand works fine for the first page of GridView data and shows 5 GridView pages, but if I switch to one of the other pages, it seems to revert to the default SelectCommand (which generates 19 GridView pages). I assume I should put my code to change the SelectCommand somewhere else. Can someone help me with where to put it? Thanks!

View 1 Replies View Related

How To Use A CheckBoxList With The Select Command

Feb 24, 2008

Hi,
I'm trying to use a CheckBoxList to display certain records in a Grid View. I have a Grid View, a CheckBoxList with four items and a SqlDataSource and when the user check or uncheck one or more items in the CheckBoxList the Grid View should show records accordingly. I’ve tried to make it work but it’s only the first checked item in the Grid View that has any effect. I use VB. Thanks 
 

View 7 Replies View Related

SessionParameters And SQL Select Command Help

Mar 24, 2008

Hi Guys,
I'm fairly new to .Net and have reached a point in the coding I can't seem to get past.
I've created a table with Visual Studio 2005 and MySQL Server 2008 (Beta) and am trying to make the "Select" button bind a result from that table (in this case, image_id) then open up that image ID in a Image details page, I've created the table in Visual Studio 2005.
Here's what I've got so far;
Page 1Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)Dim row As GridViewRow = GridView1.SelectedRowSession("session_current") = row.Cells(1).TextServer.Transfer("page2.aspx")End SubI think this page isn't at fault as it reads the parameter into a text box on page2
Page2</asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString3 %>"ProviderName="<%$ ConnectionStrings:ConnectionString3.ProviderName %>" SelectCommand="SELECT * FROM [profiles] WHERE ([profile_id] LIKE '%' + ? + '%')"><SelectParameters><asp:SessionParameter Name="profile_id" Type="String"/></SelectParameters>
 I'd sincerly appreciate any help, any one may be able to offer,
Cheers,
Craig

View 1 Replies View Related

How Can A Variable Used In SQL Select Command

Nov 8, 2004

select * from TABLE where user='jacky' ,it can working,but if like this:
dim name as string="jacky"
select * from TABLE where user=name
it won't doing,Can a variable used in SQL select command,if can,how to make it working.

View 2 Replies View Related

Sql Select Command Problem

Apr 21, 2005

i have to field in sql table
for example :
field1 : Father
Field2 : David,Sarah , Niki,John .
when i want to find for example sarah i can not becase near sarah is "," how can i solve this problem ?
i use this command :
"select * from table  where field2 like '" & textbox2.text & '""
but show me another records like sarah kimm or sarah dave but i want exact Sarah

View 6 Replies View Related

Defining A Select Command

May 17, 2006

I'm trying to populate a DropDownList from my SQL database. I'm using C# 2005 and when I compile my code I get an error. Compiler Error Message: CS0103: The name 'myConnection' does not exist in the current context
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;
public partial class Default3 : System.Web.UI.Page
{
private string connectionString = WebConfigurationManager.ConnectionStrings["mewconsultingConnectionString"].ConnectionString;

protected void Page_Load(object sender, EventArgs e)
{
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = "SELECT * FROM tblPau";
myConnection.Open();
SqlDataReader myReader;
myReader = myCommand.ExecuteReader();
myReader.Read(); // The first row in the result set is now available.
lstPau.Items.Add(myReader["PauSiteName"]);
myReader.Close();
myConnection.Close();
}
}

View 1 Replies View Related

Insert-Select Command

May 21, 2001

I need to move various records from a production database to an archive database. The fields in the two databases are identical but the archive database has an additional "Transfer Date" field. Can anyone recommend an easy way to create an SQL statement to move the record from production to archive? I've tried

INSERT INTO ARCHIVE (SELECT * FROM PRODUCTION WHERE ACCOUNTNO='XYZ')

but I get an error saying the columns among the two tables do not match (obviously because of the "Transfer Date" column). Is there a way to use a similar SQL statement that will populate the "Transfer Date" column w/ today's date?

Thanks in advance for your help.

View 2 Replies View Related

Insert Command With Select Max

Oct 17, 2013

I have a table with a column called SortOrder. It's an integer. The table also has a name and a city.I want to do an Insert and fill in SortOrder with the next higher integer, of all rows with city='NY'

Insert (name,city,SortOrder) values ('Dave','NY',
select max(SortOrder)+1 from myTable where city='NY')

View 3 Replies View Related

Using Select In Push Command

May 31, 2006

Hi All,

Does anyone know if you can add columns to a local pulled table and if so can you use a select command to push the table back and exclude the added columns.

Basically I need to know if a record has been added on the PDA so I can get an ID from the server before pushing it back. I cannot alter the sql server database because it is part another application.

Cheers,

Jiggy!

View 1 Replies View Related

SqlDataSource.Select Command Not Working?

May 26, 2007

My compiler says that the line in bold below is illegal. The error msg I'm getting is: No overload for method 'select' takes '0' arguments. How can I correct this error and execute a SELECT?
 protected void Button1_Click(object sender, EventArgs e)
{
SqlDataSource2.Select ();
 }
 protected void SqlDataSource2_Selected(object sender, SqlDataSourceStatusEventArgs e)
{string strReadyFirstName = e.Command.Parameters["@FirstName"].Value.ToString();string strReadyLastName = e.Command.Parameters["@LastName"].Value.ToString();
}
 <asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [User_ID], [User_Name], [FirstName], [LastName], [Company_Name], [Department_Name] FROM [CompanyDepartment] WHERE ([User_Name] = @User_Name)" OnSelected="SqlDataSource2_Selected">
<selectparameters>
<asp:sessionparameter DefaultValue="TheirUserName" Name="User_Name" SessionField="TheirUserName" Type="String" />
</selectparameters>
</asp:SqlDataSource>

View 1 Replies View Related

Dynamic SELECT Command In SqlDataSource

Jul 20, 2007

I have a GridView (that uses SqlDataSource1) and a Dropdownlist.  Depending upon the value selected on the DropDownList I need to select different stored procedures for the gridview.  The problem is that I can do it without taking SqlDataSource1 by using DataSet or DataTable.  But, I need to Use SQLDataSource1 for easy way of Header SORTING.  So, is there any way to change the SQLDatasource1.SELECT Command dynamically. So that, I can use different queries for the Single DataGrid. I have attached the sample code of the SqlDataSource1 I'm using.  I need to change the Command i.e. SelectCommand="usp_reports_shortages" to "usp_reports_shortagesbyID" and "usp_reports_shortagesbyDate"     depending on the value selected in the dropdownlist.  So, is there any way to do this????<asp:SqlDataSource ID="SqlDataSource1"
runat="server"
ConnectionString="<%$
ConnectionStrings:TESTDrivercommunication %>"


    SelectCommand="usp_reports_shortages" SelectCommandType="StoredProcedure">


    <SelectParameters>


        <asp:ControlParameter ControlID="lblDriver" Name="date1" PropertyName="Text" Type="DateTime" />


        <asp:ControlParameter ControlID="lblTODate" Name="date2" PropertyName="Text" Type="DateTime" />


        <asp:ControlParameter ControlID="DDlDriver" Name="driver" PropertyName="SelectedValue"


            Type="Int32" />


        <asp:SessionParameter Name="week" SessionField="s_week" Type="DateTime" />


    </SelectParameters>


</asp:SqlDataSource>

View 1 Replies View Related

Select Command Done Similar To Insert?

Aug 2, 2007

I did a successful Insert to a SQL Server today in .NET VS2005.
But before I insert I figure I better make sure the part does not allready exist in the table.
Can a check the command to determine if it has a boolan value of False and if so to INSERT as before?  Dim myCommand As New SqlClient.SqlCommand

myCommand.CommandText = "Select PartNumber From Pricing Where PartNumber = '" & var0 & "'"

'myCommand.CommandText = "INSERT INTO Pricing (PartNumber, ListPrice, PartDescription, ProductClassCode, ProductClassDescription, ProductFamilyCode, ProductFamilyDescription, ProductLineCode, ProductLineDescription) VALUES('" & var0 & "', " & var1 & ", '" & var2 & "', '" & var3 & "', '" & var4 & "', " & var5 & ", '" & var6 & "', '" & var7 & "', '" & var8 & "')"

myCommand.Connection = con


con.Open()
myCommand.ExecuteNonQuery()
con.Close() 
 

View 4 Replies View Related

SQL Command Select Statment Problem VB

Feb 19, 2008

Hi,
I have a Command that I can not get to work. I am trying to take an AVERAGE of 1 Columb and display it in a label.
ALSO what statement do I add when the Lable that is supposed to display that output is empty. Right now It gives me an Error.comm = New SqlCommand("SELECT * AVG Rating FROM Reviews WHERE CID = " & Request.QueryString("CID"), conn)
Dim SqlDataAdapter1 As New SqlDataAdapter("SELECT AVG Rating FROM Company WHERE CID = " & Request.QueryString("CID"), conn)Dim objReader As SqlDataReader
conn.Open()
objReader = comm.ExecuteReader()
objReader.Read()lblRanking.Text = objReader("Rating")
 
objReader.Close()

View 3 Replies View Related

Dynamic SqlDataSource Select Command?

Apr 25, 2008

I am trying to implement an "advanced search" feature on my ASP.NET 2.0 web form.  I have a GridView control and a SqlDataSource.  The SqlDataSource control successfully retrieves data when the SelectCommand attribute is set in the aspx page.  I need to make it so when a user clicks on a button, it can take a value from a text box and use it in the WHERE clause.  I have tried setting the SelectCommand programmatically and then DataBinding but it never accepts the new SelectCommand. What can I do to fix this?

View 5 Replies View Related

Select Command Control Parameters

May 12, 2008

 SelectCommand="SELECT [id], [ref_id], [ref_name] FROM [ref] where [delete_flag] = 'N' AND [flag_transmit] = 'N' AND [ref_name] = @ref_name ">

<asp:ControlParameter Name="ref_name" ControlId="SrchRefName" PropertyName="Text" ConvertEmptyStringToNull="false"/>

   The gridview of all the records is displayed on the page by default. There is a lookup of SSN and Name and putting values in those fields should filter the records and display only the row containing entered Name.I have trouble with the SelectCommand.  No gridview is displayed with the above command even if value is entered in the Lookup textBox (SrchRefName).But when I change the selectcommand to- (using OR) SelectCommand="SELECT [id], [ref_id], [ref_name] FROM [ref] where [delete_flag] = 'N' AND [flag_transmit] = 'N' OR [ref_name] = @ref_name ">  <asp:ControlParameter Name="ref_name" ControlId="SrchRefName" PropertyName="Text" ConvertEmptyStringToNull="false"/> the default gridview is displayed with all the records even though a value is entered in the lookup text box. Please help.  

View 2 Replies View Related

Setting The Datasource Select Command

May 22, 2008

Can someone tell me why the syntax checker is choking on the following code? It doesn't like the SQLDataSource1 reference. Protected Sub cmdSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
SqlDataSource1.SelectCommand = "SELECT * FROM users WHERE username='" + Trim(txtUsername.Text) + "' AND password='" + Trim(txtPassword.Text) + "'"
End Sub

 
Thanks

View 6 Replies View Related







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