DataSource Controls :: Database Name As A Variable?
Apr 8, 2010
Is it possible to use a database name as a variable in a SP?I use a separate database for each custromer.I also use a master database that keeps database name, ID, and Password.I then want to generate an SQL select against the appropriate Database based on the userID and password (for an XML REsponse)is this possible?Set @DBName as varchar(50)Select * from @DBName.dbo.tablename where bla bla blaNote: that the actual select is about 150 lines with multiple sub selects
View 3 Replies
Similar Messages:
Jun 28, 2010
Assigning a var with a value from a database grid
currentID = Convert.ToInt32(GridView_ABC.DataKeys[0].Value);
I get the error 'Input string was not in correct format' currentID is an integer var. When I hover over the GridView_ABC.DataKeys[0].Value it is """, it should be an integer.
View 7 Replies
May 20, 2010
I have several web forms which use a GridView linked to a DataSource control which is defined at design time as follows:
<cc1:pgsqldatasource
id="dsStates"
runat="server"
connectionstring="<%$ ConnectionStrings:PgSqlConnection %>"
oldvaluesparameterformatstring="Original_{0}"
providername="<%$ ConnectionStrings:PgSqlConnection.ProviderName %>" >
</cc1:pgsqldatasource>
As you can see, the connectionstring parameter is defined to a specific connection string name and I need to be able to set such a parameter to a different value, for example, to a session variable content.
View 1 Replies
Oct 27, 2010
I am storing a custom "Organisation" object as a session variable. One of the properties of the Organisation object is "OrganisationID" (integer). I have a DataSource that requires a parameter value to run, and I want to use a SessionParameter to populate this. In a previous version, I stored the OrganisationID directly as a session variable. In that case, I could easily access it like this:
[Code]....
However, how do I now access the OrganisationID property of an "Organisation" type session variable (called "Organisation")? I have tried this, which does not seem to work: <asp:SessionParameter Name="OrganisationID" SessionField="Organisation.OrganisationID" Type="Int32" />
View 2 Replies
Jan 28, 2010
Would anyone know how to pass a variable to SqlDataAdapter. Here is my code.
TextBox1.Text = 1
Dim textboxval
As
String
textboxval = TextBox1.Text
connection.Open()Using connection
As
New SqlConnection("Data Source=CHRIS-PCSQLEXPRESS;Initial Catalog=TorGHL;Integrated Security=True")
Dim dapubcb
As
New SqlDataAdapter("SELECT [BarName], [MenuSubId], [Address], [PhoneNo], [BarURL], [Email]
[BarDescription], [Id], [bg_long], [bg_lat] FROM [BarDetails] WHERE [MenuSubId] = texboxval ", connection)
View 5 Replies
Sep 10, 2010
I have an objectDataSource which uses my stored procedure GetNotifications
And my GridView is bound to that objectDataSource
the only problem is that my stored procedure requires the variable @UserName and then returns the values for that username, but I do not know how to pass the variable to the objectDataSource, does anyone know the code for this?
I can get userName from HttpContext.Current.User.Identity.Name but how do I pass that to the objectDataSource?
View 7 Replies
Jul 7, 2010
I am trying to pass a variable within a selectcommand statment in ASP.NET and I have researched online how to do it but I can't seem to find a way to do it...What I am trying to do is write a code for a web page that will display a page with useful links on it where the links are separated into different topics and where everything is dynamically grabbed from a database. This is what I have so far:
<!-- Start MainContentRegion -->
<h1>Useful Links</h1>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
[]code...
View 4 Replies
Jan 21, 2010
I want query like this
declare @stateQuery as nvarchar(200)
if @stateid is null
set @stateQuery=''
if @stateid is not null
set @stateQuery='and tbl_city.stateid ='+cast(@stateid as nvarchar(10))
set @length=(select top 1 len(dbo.Tbl_city.cityName) FROM dbo.tbl_city INNER JOIN tbl_cityinfonew ON dbo.tbl_city.cityId = tbl_cityinfonew.cityId where (tbl_cityinfonew.language =@language )+cast( @stateQuery as nvarchar(100)) order by tbl_cityinfonew.createdate desc)
I don't want to use the exec @string.
View 6 Replies
May 5, 2010
I am using a data list to display some value retrieved from a SQL query. My problem is that I would like to insert a variable for the field of ISDS_454.dbo.booksusers.userID. The variable has already been declared and stored upon page load. I just need some way to get it within the SQL query for the datalist.
<script runat="server"> Sub Page_Load()
Dim ID As String = "D07AD7E0-8E34-4C18-9B4D-10576B0CC6BF" End Sub
</script> <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate> fic: <asp:Label ID="ficLabel" runat="server" Text='<%# Eval("fic") %>' />
<br /> <br /> </ItemTemplate> </asp:DataList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ISDS_454ConnectionString %>" SelectCommand="Select COUNT(*) as fic
From ISDS_454.dbo.Books, ISDS_454.dbo.booksusers, ISDS_454.dbo.Genre
where ISDS_454.dbo.Books.ISBN = ISDS_454.dbo.booksusers.ISBN
And ISDS_454.dbo.Genre.Genre_ID = '1'
And ISDS_454.dbo.booksusers.userID = 'D07AD7E0-8E34-4C18-9B4D-10576B0CC6BF'">
</asp:SqlDataSource>
View 6 Replies
Mar 25, 2010
I've done some SSIS package work in the past, but am by no means an expert.
I want to use an SSIS package to do the following:
1. Get the file name of the newest file in a windows folder (using a filename template like his: filename_ *.txt where the * part is always a date in the format of yyyy-mm-dd.
2. Use that file name in later portions of the SSIS package by reading the file and transferring data from it to a SQL table using a Data Flow task.
and use the result (which should be the name of the newest file) to open that file and pull data out of it and into a 2nd SQL table. I admit, I'm not sure how to use the dynamic result of this SELECT query as the file name in a flat file connection manager.
View 6 Replies
Oct 21, 2010
I am rather confused as how or where to declare this variable in asp.net.
[Code]....
Whenever i put this in my sqldatasource for it is asking me to Define Parameters:
The wizard has detected one or more parameters in your SELECT statement. For each parameter in the Select Statement, choose a source for the parameter's value.
View 4 Replies
Jun 28, 2010
i want to ask how to i set variable in asp:sqldatasource in sqlcommand in asp.net c#....
This is my code
asp.net
<dx:ASPxListBox ID="lsAssignToko" runat="server" DataSourceID="SqlDataSource6"
TextField="NAMA" ValueField="ID" AutoPostBack="true"
EnableCallbackMode="True" SelectionMode="CheckColumn"
OnSelectedIndexChanged="lsAssignToko_SelectedIndexChanged">
<Columns>
<dx:ListBoxColumn FieldName="ID"/>
<dx:ListBoxColumn FieldName="NAMA" />
</Columns>
</dx:ASPxListBox>
<asp:SqlDataSource ID="SqlDataSource6" runat="server"
ConnectionString="<%$ ConnectionStrings:Ora2010 %>"
ProviderName="<%$ ConnectionStrings:Ora2010.ProviderName %>"
SelectCommand="SELECT ID, NAMA FROM REF_TOKO WHERE ID IN ( :inTOKO ) ORDER BY NAMA">
<SelectParameters>
<asp:SessionParameter Name="inTOKO" SessionField="inTOKO" Size="200" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
c#
string dummy = "";
string data = "";
string inTK = "";
string inTOKO = "";
//string inTOKO1 = "";
int pot;
for (int i = lsToko.SelectedItems.Count - 1; i >= 0; i--)
{
string tok = lsToko.SelectedItem.Text.ToString();
data = lsToko.SelectedItem.Value.ToString();
dummy = dummy + "" + data + ",";
int index = lsToko.SelectedItem.Index;
lsToko.Items.RemoveAt(index);
}
if (lsToko.SelectedItems.Count <= 1)
{
inTK = dummy.Length.ToString();
pot = int.Parse(dummy.Length.ToString()) - 1;
inTOKO = dummy.Substring(0, pot);
}
Session["inTOKO"] = inTOKO;
the problem is where in my variable inTOKO consist of couple of value...
Example
while variable inTOKO = one value success but while value inTOKO = two value error
inTOKO = 1101111 => success
inTOKO = 1101111,1211321 => not success
View 1 Replies
Jan 17, 2011
It seems really easy to output a sqldatasource into a table but really hard to output a sqldatasource into a variable.
View 2 Replies
Sep 3, 2010
I create a variable in code behind to save today's date.
[Code]....
And I want to save it as a parameter for an accessDataSource but I'm not finding anywhere that tells me how to do this properly. My attempts thus far have been
[Code]....
View 4 Replies
Jul 8, 2010
I'm making a page with a DropDownList (called ddlSupp) that contains several suppliers, and I populate it with an SqlDataSource, all in front code.
In another part of the page I make a CheckBoxList, and populate it again with an SqlDataSource. The select command of the SqlDataSource is a procedure call to my MySQL database. However, what the CheckBoxList gets populated with depends on who is selected in ddlSupp. How do I make a variable in front code that will take the value from ddlSupp and populate my checkbox accordingly?
Here is my code:
[Code]....
I get a MySQL error at (<%$ddlSupp.SelectedValue %>) so I know the wrong value is being passed into the query. How can I fix this?
View 1 Replies
Jan 7, 2010
I need to use a global variable as a parameter for the SqlDataSource element. I capture the user Name when he/she logs in:
Public UserName As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
UserName = Page.User.Identity.Name
End Sub
Then, I need to use the UserName to search the SQL DB and show only logged user personal information.
SelectCommand="SELECT * FROM [Member] where [UserID]= UserName"
What is the sintaxe to use a global variable into the SQL Select Command?
View 10 Replies
Jun 8, 2010
I am modifying a rather large ETL package using BIDS. It builds a datawarehouse, so there are many sources and a single destination. There are quite a few data flow tasks, and their connection strings are read into variables from an encrypted source. All the data flow tasks are arranged serially because of variable locking issues - occasionally two DFTs attempt to simultaneously lock the variable and it fails. I realize there are script solutions out there, but I am looking for perhaps a more elegant (easier) solution than to apply scripted solutions to tons of packages over something so trivial.
I came across the "RetainSameConnection" connection property, and I have a hunch this could be the solution. My reasoning is: If there's only one connection to a data source, there should only be one read operation from the variable. At least, it makes sense when SOURCING.As for destinations, I'm not sure if it's a good idea to have data from multiple sources flowing in through a single connection.This is my first week working in ETL so I don't know all the nuances of databases, ETLs, connections, etc.
View 1 Replies
Apr 16, 2010
I have defined a column in a table I have in an SQL database as being a Time variable and not DateTime. How do I convert the time data that I get from my table into a text string using C#?
View 6 Replies
Jan 18, 2010
I've created a SQL stored proc and want to change it to use a local variable to reduce process time..
Major lines of my SP:
[Code]....
I've been trying to use a variable for AVG(AA.Count) so that I don't have to process it three times,
[Code]....
=> this stored proc does not work, and I am not too sure where I should declare my local variable to use it in SELECT statement..
View 9 Replies
Apr 12, 2010
I'm working with Front Page 2003 & ASP v. 1.5 For an online auction, I have created a table with 3 columns: username, amount, highbid ORDERED by Amount DESC.
I want to look at the 2nd record in the table, create a variable from the "amount" field, add 1,000 to it and post it in the first record's "highbid" field.
Then display on my web page the first record "username" and "highbid"
I have been stumbling around with trying to create a custom query in the database results wizard of FP 2003.
View 1 Replies
Mar 7, 2011
I should perform a Query like this Select * from produtcts where model like @MODEL Now if model is selected from combobox, it should be Select * from produtcts where model like '%MODEL1%' while, if selected chooise is null, it should be like each element in my combobox. how should i do this (in SqlDataSource)
View 5 Replies
Mar 24, 2011
I can't figure out whats wrong with my contact page. I am getting this error when executing. It complied fine, I see the page as it suppose to. Then I enter all my contact information and click submit I am getting this error. Can someone guide me. Here is the error msg
must declare the scalar variable @txtSubject Here is the part of relevant code
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim ContactDataSource As New SqlDataSource()
ContactDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
ContactDataSource.InsertCommandType = SqlDataSourceCommandType.Text
ContactDataSource.InsertCommand = "INSERT INTO Enquery (EnqSubject,EnqFirstname, EnqLastname,EnqContactNumber,EnqEmail,EnqMsg,EnqDateTimeStamp,EnqIPAddress) values (@txtSubject, @txtFirstname, @txtLastname,@txtPhone,@txtEmail,@txtMsg, @txtDateTimeStamp,@txtIpAddress)"
[Code]....
View 3 Replies
Jun 23, 2010
I get a casting error on line #8 below which reads "db.UserID = Session("UserID")". What would be the correct way to cast this? The datatype of the DB field is GUID.
[Code]....
View 4 Replies
Mar 9, 2010
I wrote a linq code to read from database if its value is equal to textBox that user enters.
I dont wanna show the result in Gridview,so jz I wanna use that value. The code I wrote is
var sql = from x in db.Managers
where x.M_Name == TextBox1.Text.ToString()
select x.M_Name;
in this code I'm selecting only the name that user entered in textBox
so i want to do like tis
String Name = sql.ToString();
means to store the value in string. so the problem is i can not assign the var to string.
View 2 Replies
Mar 1, 2011
I'm getting "Must declare the scalar variable "@ShowTypes"." when I try to run the code below.
[Code]....
View 3 Replies