Passing Xml To Sql Server

Jun 16, 2004

Hi,


i manage to passs an xml string to sql server based on the reference site(http://www.eggheadcafe.com/articles/20030627c.asp by Robbe Morris). From his way, i can only pass XML in this format


<cart>


<order id="10">


<prod id="1" qty="1"/>


<prod id="2" qty="3"/>


</order>


</cart>





Note : the value is stores as attribute (<prog id="1") . I am just wonder can i actaully pass my xml string to sql Server with this format


<cart>


<order id="10">


<prod>





<id>1</id>


<qty>3</qty>





</prod>


</order>


</cart>


and how can i read the value from this format in my stored procedure?





Regards,


Dorris

View 5 Replies


ADVERTISEMENT

Passing A Linked Server As A Variable?

May 25, 2006

Anyone got any Ideas on how to set tax...TXZip as a variable in the following script segment?



Select
RecordID = Identity(int,1,1),
Zip_ZipCode,
Zip_SignatureCode
Into #Temp
from tempstatezip
where State = @State

Delete From tax...TXZIP ------------------------------

While (Select Count(*) from #temp)>0
Begin

Set @rowVal = (Select top 1 RecordID from #Temp)


Id like to set this up in a store procedure so I can pass the state variable to it.....

Having problems setting a linked server as a variable thou.....
Example of what I want.....
Delete from @StateVar
But as a linked server I always get...

declare @StateVar Varchar(11)
Set @StateVar = 'Tax...TXZip'
Select * from @StateVar

Msg 137, Level 15, State 2, Line 3
Must declare the variable '@StateVar'.

Any Ideas?

View 2 Replies View Related

Passing A Binary Value To Sql Server 2005

Jun 27, 2007

I have been pulling my hair out on this.



I am trying to pass a binary value from an ASP.NET app to a VERY simple stored proc, and I can NOT get it to work!



Here is some of my code:






Code Snippet

ALTER PROCEDURE [dbo].[sp_SelectAppointments] @PID VarChar(50)



AS

BEGIN

--set @PID = 0x00000000000000B1

--PLEASE NOTE HERE THAT THE ABOVE VALUE(WHEN UNCOMMENTED) RETURNS RECORDS

--WHEN THE VALUE IS IN QUOTES (AS IT WOULD BE) IT DOES NOT WORK

SET NOCOUNT ON;

SELECT Appt_Date, Appt_Description, Rn_Appointments_Id

FROM Rn_Appointments

WHERE project = @PID --Project is a binary field.

END



I created a Dataset in VS2005, and here is the code that passes the value to the Dataset:




Code Snippet

Dim PID As String = Request.QueryString("pid")

PID = "0x00000000000000B1"

Dim da2 As New sp_SelectAppointmentsTableAdapter

GridView1.DataSource = da2.GetData2(PID)

GridView1.DataBind()



What am I missing?? Can anybody please help me out here?



Thank you.



Steve

View 1 Replies View Related

SQL Server 2012 :: Variable Not Passing Through To Expression

May 22, 2014

I have created a variable in a SQL Task and assigned it to a string variable. When I debug the container with a breakpoint, I can see the correct date value being assigned to the variable.

I have an ADO Net source setup to an Oracle connection. I need to pull the Oracle data down that has an updated date greater than the updated date in my ODS.

My issue is that the variable is not being passed through to my expression that I use for an ADO Net source.

"SELECT * FROM BI_EDW.GL_JE_HEADERS WHERE LAST_UPDATE_DATE > To_Date('" + (DT_WSTR, 19) @[User::varLastUpdateDate] + "','yyyy-mm-dd hh24:mi:ss')"

View 2 Replies View Related

SQL Server 2008 :: SSRS Passing Parameters In URL?

May 20, 2015

i have a url that opens my report with no entries in the parameters i then add &Search=96200 at the end of the URL and still the parameter is blank

View 2 Replies View Related

SQL Server 2012 :: Passing Sum To Stored Procedure

Sep 21, 2015

Is it possible to pass a sum of vars to a SP ?I've tried this but it gives me an error

exec mysp
@param = (@var1 + @var2)

View 1 Replies View Related

SQL Server 2008 :: Passing Empty TVPs

Oct 15, 2015

I have an inline table valued function (function1) where I need to call another inline function which requires 4 TVPs (function2).

Unfortunately, given the limitations of my php calling program I cannot pass a TVP to function1. How can I make that call to function2 (using empty TVPs) from function1 without putting any TVP parameters on function1?

I could do this by creating a multistatement wrapper function that declares the empty tables and passes them to function1, but I was trying to avoid doing this. Is there any other way?

function1:
ALTER FUNCTION [dbo].[function1] (
@ListId INT,
@StartSize INT = NULL,
@EndSize INT = NULL,
@StartDate DATE = NULL,
@EndDate DATE = NULL

[Code] .....

View 1 Replies View Related

Sql Server Job Output File -passing It Onto Second Step

Jul 23, 2005

How do we pass on the step1 output file to step2 of the same job? Iwould like to know the current job's output file programmetically,instead of hard coding it. Any idaes would be appreciated.Thanks

View 10 Replies View Related

Passing Variables From SQL Server To Reporting Services

Apr 6, 2007

I have a report that I'm trying to automate. Basically I want to create a cursor of containing authors, I want to run my report for that particular author, save the report, and move to the next author in the cursor. I want to continue this process until there's no more authors left in the table. Is this possible with reporting services 2005? If so how do I communicate the value from my cursor, to my report?

View 4 Replies View Related

Reporting Server - Passing Parameters Programtically

Jun 28, 2007

We've developed several reports where you can type in / select variables and run them, affecting their outcomes.



We'd like to change this so if the user clicks on a link from our Intranet, this takes them straight to the report with the appropriate parameter(s) - rather like the "jump to report" function within a report - i.e. the url for that function...


Is this possible?



Steve

View 4 Replies View Related

Passing XML From Sql Server 2000 In Stored Procedure

Jul 23, 2007

Hi,
I m wanting a stored procedure to pass an XML string from a stored procedure to my application. Whats the best way to achieve this?

Hope you can help

Thanks

Paul

View 10 Replies View Related

Passing Like Criteria In Parameter To SQL Server Stored Procedure

Dec 13, 2006

Hello All,
 I was hoping that someone had some wise words of wisdom/experience on this.  Any assistance appreciated... feel free to direct me to a more efficient way... but I'd prefer to keep using a stored proc.
  I'm trying to pass the selected value of a dropdownlist as a stored procedure parameter but keep running into format conversion  errors but I am able to test the query successfully in the SQLDatasource.  What I would like to do is this: select * from tblPerson where lastnames Like "A%" . Where I pass the criteria after Like.   I have the values of the drop down list as "%", "A%", "B%", ....
I've been successfully configuring all of the other params, which includes another dropdown list (values bound to a lookup table also)... but am stuck on the above...
 Thank you for any assistance,
 

View 3 Replies View Related

FoxPro Linked Server And Passing Variable Within OPENQUERY

Mar 8, 2005

I'm posting this because I found this solution after much digging.

The goal here is to incorporate a variable parameter within a OPENQUERY and, ultimately build a dynamic Where clause for use within a OPENQUERY linked server routine. I'm posting because I spent a lot of time trying to get this to work and also, have seen other posts here that hinted it wasn't doable.

First of all - there a good quick article that gets close for FoxPro and possibly works as is for ACCESS:

http://support.microsoft.com/default.aspx?scid=kb;en-us;314520

Here's code for a solution:

DECLARE @OPENQUERY nvarchar(4000),
@TSQL nvarchar(4000),
@FAMILY CHAR(10)

SET @FAMILY='Touring'
SET @OPENQUERY = 'SELECT * FROM OPENQUERY(VFP,'''

SET @TSQL = 'select cov,family,model from vinmast where family='+'['+@FAMILY+']'')'

EXEC (@OPENQUERY+@TSQL)

All shown are single quotes.

In Visual Foxpro, ' ' or " " or [ ] can be used a delimeters

In addition, if wanting to build a dynamic where clause, you could do something like:

SET @TSQL = 'select cov,family,model from vinmast '
IF <some condition met to include FAMILY filter>
Begin
SET @TSQL=@TSQL+'where family=['+@DUTFAMILY+']'''
SET @TSQL=@TSQL+ ')'
End
-----------------
Here's the entire Stored Procedure:


CREATE PROCEDURE dbo.ewo_sp_DUTLookup
(
@DUTPROJECT char(25)=NULL,--Project
@DUTFAMILY char(10)=NULL,--Family
@DUTMODEL char(20)=NULL,--Model
@DUTYEAR char(4)=NULL,--Model Year
@DUTBEGIN char(25)=NULL,--Beginning of COV/DUT number
@DEBUG int=0
)


AS

DECLARE @OPENQUERY varchar(4000),
@TSQL varchar(4000),
@TWHERE varchar(4000),
@intErrorCode int

select @intErrorCode = @@ERROR,
@TSQL='',
@TWHERE=''


IF @intErrorCode=0
Begin
SET @OPENQUERY = 'SELECT * FROM OPENQUERY(VFP,'''
SET @TSQL = ' select dut_pk,cov,family,model,project,modelyr from vinmast '
End

set @intErrorCode = @@ERROR

IF @intErrorCode = 0 and
@DUTFAMILY is not NULL or
@DUTMODEL is not NULL or
@DUTPROJECT is not NULL or
@DUTYEAR is not NULL or
@DUTBEGIN is not NULL
set @TWHERE=' where '



-- Check for Family criteria
If @intErrorCode = 0 and @DUTFAMILY is not NULL and Len(@TWHERE)>0
SET @TWHERE=@TWHERE+' family=['+@DUTFAMILY+'] AND '
set @intErrorCode = @@ERROR

-- Check for Model criteria
If @intErrorCode = 0 and @DUTMODEL is not NULL and Len(@TWHERE)>0
SET @TWHERE=@TWHERE+' model=['+@DUTMODEL+'] AND '
set @intErrorCode = @@ERROR

--Check for Project criteria
If @intErrorCode = 0 and @DUTPROJECT is not NULL and Len(@TWHERE)>0
SET @TWHERE=@TWHERE+' project=['+@DUTPROJECT+'] AND '
set @intErrorCode = @@ERROR

--Check for Model Year
If @intErrorCode = 0 and @DUTYEAR is not NULL and Len(@TWHERE)>0
SET @TWHERE=@TWHERE+' modelyr=['+@DUTYEAR+'] AND '
set @intErrorCode = @@ERROR

--Check for beginning of DUT
If @intErrorCode = 0 and @DUTBEGIN is not NULL and Len(@TWHERE)>0
Begin
SET @DUTBEGIN=RTRIM(@DUTBEGIN)
SET @TWHERE=@TWHERE+' substr(cov,1,'+cast(len(@DUTBEGIN) as char(20))+')=['+@DUTBEGIN+'] AND '
End
set @intErrorCode = @@ERROR


IF @intErrorCode=0 AND substring(@TWHERE,Len(@TWHERE)-3,4)=' AND '
Begin
set @TWHERE=Substring(@TWHERE,1,Len(@TWHERE)-3)
select @intErrorCode=@@ERROR
End



SET @TWHERE=@TWHERE+''')'

IF @debug<>0 and @intErrorCode=0
Begin
print @intErrorCode
print @OPENQUERY
print @TSQL
print @TWHERE
print @OPENQUERY+@TSQL+@TWHERE
End

IF @intErrorCode=0
EXEC (@OPENQUERY+@TSQL+@TWHERE)
GO

Peter

View 2 Replies View Related

SQL Server 2012 :: Error When Passing Multiple Rows

Apr 20, 2015

I am getting error when I passed multiple rows in less than condition:

create table #t1
( ID int)
INSERT INTO #t1

SELECT 1 UNION ALL SELECT 5 UNION ALL SELECT 8
CREATE TABLE #t2
(ID int)
INSERT INTO #t2
SELECT 3 UNION ALL SELECT 20 UNION ALL SELECT 4

SELECT ID FROM #t2
WHERE ID < (SELECT ID FROM #t1)

Error is: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

How to pass multiple values in this condition?

View 2 Replies View Related

Integration Services :: Parameter Passing From Server Agent

Jun 12, 2015

I'm calling the SSIS  packages through SQL agent job. The packages have variables defined with default values.The parent packages have no package configuration. The child packages have package configuration of ‘Parent Package variable’ type The variables are being passed from the job. The job calls the parent package which loops though the child packages. I would like to know how the variables traverse through the packages and the jobs?

Another doubt not related to above. I am unable to make any changes to the connections. Whatever changes I make it is getting reverted to the original if I click elsewhere. So as a workaround I view the code in XML and change.

View 2 Replies View Related

Passing Multi-Selected Items To Reporting Server Using A URL

Nov 6, 2007

I have designed a report that allows the user to select multiple values to be passed to SSRS. When I deploy and run the report from Report Manager I can select 1 to n values and then run the report. It works great. Now I attempt to call Reporting Services from my Web Site. I format the URL and attempt to pass the mutliple values in the URL. An example would be http://YadaYada&rs:Command=Render&rs:Format=HTML4.0&rcarameters=false&OrderTypeID='1,2' The report uses a Stored Procedure that is expecting @Ordertype Varchar(1000). And Yes, the Stored Procedures handles the multiple values being passed to it. What I receive is an error message (rsReportParameterTypeMismatch). Any suggestions on how to pass these values?

Thanks in Advance
Tom

View 2 Replies View Related

Passing A List/array To An SQL Server Stored Procedure 2005

Aug 16, 2007

Hi, I m using sql 2005 as a back end in my application...
I am useing Store procedure..for my data in grid..
 
ALTER PROCEDURE [dbo].[ProductZoneSearct]
(
@Productid char(8),@Proname char(8),@radius int,@mode varchar(5) = 'M',@Zone nvarchar(1000),)
ASSET NOCOUNT ON;Create Table #Product (ProductID int, TimeEntered datetime, DateAvailable datetime, Productname varchar(80), City varchar(50), State char(4),Miles decimal, Payment varchar(40),UserID int, Phone varchar(15))
Insert #Product Select ProductID , TimeEntered, DateAvailable, Productname ,City,State,miles,Payment ,Miles, UserID, Daily, PhoneFrom [tblproduct] Where city IN (@Zone)
Select ProductID TimeEntered, DateAvailable, Productname City,State,miles,Payment ,Miles, U.Phone As phoneNumber, Company, , L.Phone As cmpPhone From #Product As L Left Join (Select UserID, Company, Phone, From [User]) As U On U.UserID = L.UserID  Order By DateAvailable
 
if i pass value in "where city in (@Zone)" and @Zone ='CA','AD','MH'  then it can not get any result..but if write where city in ('CA','AD','MH') then it give me perfact result..
I tried to below syntax also but in no any user Where city IN ('+@Zone+')
In short if i pass value through varibale (@Zone) then i cant get result...but if i put  direct value in query then only getting result..can anybody tell me what is problem ?
Please Hel[p me !!!
Thank you !!!

View 5 Replies View Related

SQL Server 2012 :: Passing Parameters To Table Valued Function?

Mar 13, 2014

I am creating a function where I want to pass it parameters and then use those parameters in a select statement. When I do that it selects the variable name as a literal not a column. How do I switch that context.

Query:

ALTER FUNCTION [dbo].[ufn_Banner_Orion_Employee_Comparison_parser_v2]
(
@BANNER_COLUMN AS VARCHAR(MAX),
@ORION_COLUMN AS VARCHAR(MAX)
)
RETURNS @Banner_Orion_Employee_Comparison TABLE

[code]....

Returns:

I execute this:

select * from ufn_Banner_Orion_Employee_Comparison_parser_v2 ('a.BANNER_RANK' , 'b.[rank]')

and get:

CerecerezNULLNULLa.BANNER_RANKb.[rank]

View 7 Replies View Related

SQL Server 2012 :: Open Query To PostGres Passing Parameters?

Mar 24, 2014

Looking to pass in the @targetDbName into the Open Query.

The target DB is PostGres and requires 2 single quotes around the dataset name.

I have tried many possible variations using the '+ @variableName +'

USE JonathanDB
declare @dqzDateVer int;
declare @targetDbName varchar(25);
select @targetDbName = DB_NAME();
select @dqzDateVer = dqz_date_ver FROM OPENQUERY(ofr_meta_db, 'select dqz_date_ver from ofr_registry.dataset_feed_state where dataset_name=''JonathanDB'' and state = ''Done'' order by row_iddesc limit 1');
print @dqzDateVer ;
print @targetDbName;

View 1 Replies View Related

SQL Server 2012 :: Passing Date Parameter To Stored Procedure?

Oct 9, 2014

I am trying to pass a date parameter to a stored procedure.

I pass the actual date as a string but keep getting errors that the string variable cannot be converted to a date whatever I do.

Basically, this works:

DECLARE @DDate DATETIME
SET @DDate = convert(datetime, '2004-01-01',101 )

But this returns an error:

DECLARE @strdate VARCHAR
SET @strdate = '2004-01-01'
DECLARE @DDate DATETIME
SET @DDate = convert(datetime, @strdate,101 )

What am I doing wrong?

View 8 Replies View Related

SQL Server 2008 :: SSIS - Passing Column Delimiter From A Variable?

Mar 13, 2015

I am building a generic SSIS where it takes a text source file and converts to a destination source file . However in the process I want to set the row delimiter and the column delimiter dynamically through the package variable. So that I can use it for any file transfer.

I saw the option for row delimiter in the file connection string property but did not see any column delimiter option.

View 3 Replies View Related

SQL Server 2008 :: Updating Geography Column By Passing In Lat And Long For That Row

Apr 28, 2015

I have the following in my table. As you can see the Geo field is null (which is of type Geography), what I'm trying to do is populate that with an update statement by comparing the latitude and longitude for each row so I can then work out the distance, I've been following this tutorial to workout the distance which is giving me the desired results

[URL] ....

The issue I have is passing in the points i.e latitude and longitude and then updating the Geo field for the row, I currently have 11938 rows in my DB so I need to run this against all of them. I thought I had it I was thinking of update then select from the source but then I realized I need to pass the lat and long in for the points and that's where I got confused

View 4 Replies View Related

MS Access Front End To SQL Server Problem Passing Form Value To Report

Jul 23, 2005

I just changed my Access 2002 database to a SQL Server ADP project. Ihad a form where the user entered a value into a text box and when acommand button on the form was clicked a Report was opened. The reportsrecord source is a query. The query uses the value from the form textbox to restrict the query.Table name = EggsTableone of the columns in the table is named: EggColorForm name = EggColorFormForm text box name = ColorTextBoxThis sql worked for the query before I converted to SQL:SELECT EggsTable.EggColorFROM EggsTableWHERE (((EggsTable.EggColor)=[Forms]![EggColorForm]![ColorTextBox]));This no longer works. Can I change the syntax somehow to get this towork? I tried dropping the brackets around the word "Forms", I trieddropping all the square brackets, etc., nothing worked.I also tried just opening the report with the report's Server Filterproperty set to:EggColor=N'Forms.EggColorForm.ColorTextBox'I tried using the Report's open event to pass the form value directlyto the report. I tried setting a variable from the text box value onthe form. So far, nothing works. Any ideas?

View 7 Replies View Related

SQL Server 2014 :: Passing Multiple Columns Values From Query To One Variable?

Aug 10, 2014

Is it possible to assign multiple columns from a SQL query to one variable. In the below query I have different variable (email, fname, month_last_taken) from same query being assigned to different columns, can i pass all columns to one variable only and then extract that column out of that variable later? This way I just need to write the query once in the complete block.

DECLARE @email varchar(500)
,@intFlag INT
,@INTFLAGMAX int
,@TABLE_NAME VARCHAR(100)

[code].....

View 1 Replies View Related

SQL Server 2014 :: Passing Malformed Email Address To Send Mail Task?

Feb 5, 2015

I am implementing a fax solution (Right Fax) and pulling email information from a table and passing into a variable. In order to send out a fax via email, the syntax is in the following example below:

Example:

To send a fax from Outlook to Jane Doe at 555-1212, enter:

[RFAX:Jane Doe@/FN=555-1212]

When the following syntax gets passed into the Send Mail Task, into the "To" line and the package is executed I'm receiving the following.

[Send Mail Task] Error: An error occurred with the following error message: "The specified string is not in the form required for an e-mail address.".

[Send Mail Task] Warning: The address in the "To" line is malformed. It is either missing the "@" symbol or is not valid.

I realize it’s a malformed email address. Is it possible to create a group and instead of the fax syntax pass the group name?

View 8 Replies View Related

Parameter Passing In SQL Server 2005 Integration Services (SSIS) 2005 From VB.Net2005

Sep 7, 2007

Is it possible to parm in a value to a SSIS

in my SSIS i have a variable;

Name : FileName
Scope : PackageName
Type : String

Value : ""

I have tried adding the following code in my vb.net project ;

pkg.Variables("filename").Value = "C: emp estfile.001"
pkg.execute()

but come up with the following error

A first chance exception of type 'System.MissingMemberException' occurred in Microsoft.VisualBasic.dll
Public member 'Variables' on type 'IDTSPackage90' not found.

can anyone help ?

View 11 Replies View Related

Parameter Passing In SQL Server 2005 Integration Services (SSIS) 2005

Jan 16, 2007

Hi All,

Parameter passing in SSIS 2005 sometimes appears to be a cumbursome task. I have been digging into this topic for quite some time and here i note down some simple steps to demonstrate parameter passing at Package level.

(1) Create a SSIS project using Business Intelligence 2005 Or VS 2005.

(2) Create datasource (.ds) and Data Source View as required.

(3) A default SSIS Package by the name Package.dtsx is created. Double click this and you are shown tabs for Control Flow, Data Flow, Event Handlers, Package Explorer. On the Control Flow, drap and drop Execute SQL Task from Control Flow Items in the toolbar.

(4) Lets now create a variable at Package level. Right click anywhere in the control flow box (not on the Task created in Step 3 above). Click on the Variables on the context menu displayed. Variables window appears on the left of the screen. Click the Add Variable box in this window to create a variable. Name it var1 (or whatever you may like), Scope as Package, DataType as String and Value as MyValue. This is only the default value.

(5) Now let us edit the SQL Task created in Step 3. Double on it, on the General tab you can change its Name, Description. Set ResultSet as None. We shall proceed to execute a stored procedure by name MySPName and pass it a parameter. Set ConnectionType as OLE DB. Select the connection you creates in step 2. Set SQLSourceType as Direct input. SQLStatement as MySPName ? . Note the ? mark after the name of the stored procedure. This is important to accept the variable value (var1) created in Step 4.

(6) Select Parameter Mapping tab now. Click on Add button. Select the Variable Name as User::var1. This is the user created variable of Step 4. Select Direction as Input, DataType as Varchar and Parameter Name as @var1. Click on OK now.

(7) This sets up the basic of parameter passing. Compile the project to verify everything works. Right Click on the SQL Task and select Execute Task. This will execute the package taking default value of the variable. This can be used along with dtexec command with /set option to pass the parameter at command prompt.





View 5 Replies View Related

Passing Parameter To The Sql Server Report Using Report Viewer Control

Dec 29, 2006

Hi,

I want to give filtering criteria in my SSRS report.

I have drop down list control having list of Email's of clients.

So, how can i pass the value of the particular Email id in my SSRS report using Report Viewer control?

How can i pass user input as parameter in my report using visula studio 2005?



Thanx,

Ruja

View 1 Replies View Related

PASSING VALUE

Apr 24, 2007

Help!

Attached proc is working fine. But how should I pass the value of @LexNexID without manul key in the value. How can I call this proc. to update comment in table tblSEMS_FTP_FINAL automatically

Thk

CREATE PROCEDURE DBO.SP_SEMS_ADD_COMMENT (
@lexnexid int,
@commentstring varchar(4000)
)
AS

DECLARE @Comment varchar(4000)
--DECLARE @CommentString varchar(4000)
--DECLARE @LexNexID INT

--SET @LexNexID = 1
SET @CommentString = ''






DECLARE Test CURSOR
FOR

SELECT
convert(varchar(4000),Comment) COMMENT
FROM dbo.TBLSEMS_FTP
WHERE LEXNEXID = @LexNexID
OPEN Test

FETCH NEXT FROM Test
INTO @Comment

WHILE @@FETCH_STATUS = 0
BEGIN

SET @CommentString = @CommentString + @Comment + '{CR}{LF}' + ' '

FETCH NEXT FROM Test
INTO @Comment
END

CLOSE Test
DEALLOCATE Test

--PRINT @CommentString


update tblSEMS_FTP_FINAL
set comment = @CommentString
where lexnexid=@LexNexID



GO

View 6 Replies View Related

Passing C# Value To The ASP SQL Query

Mar 31, 2007

Hi Guys,
Im trying to pass a value from a C# page to the corresponding ASP page.
I want to use this value in my SQL Query on the asp page within a Details View.
Ive made the variable public in c# page.
And im trying to concatenate it to my sql query within the <asp: SqlDataSource.
Thanks.
 

View 12 Replies View Related

Passing UserName To SQL

Jul 8, 2007

A beginner's question I'm sure.  When visitors have logged into my site, how do I then use their UserName as a parameter in an SQL WHERE clause so that I can pull up their detailed information.  I'm using VB if additional code is required.
Thanks in advance.

View 2 Replies View Related

Parameters Passing

Mar 14, 2008

Hi,
 how to pass paremeters in sqldataadapter? here iam checking authentication using sqlcommand and datareader
like that if iam checking authentication using dataset and sqldatareader how to use parameters?
 
SqlConnection cn = new SqlConnection("user id=sa;password=abc;database=xyz;data source=server");
cn.Open();
// string str = "select username from security where username='" + TextBox1.Text + "'and password='" + TextBox2.Text + "'";
string str = "select username from security where username=@username and password=@password";
SqlCommand cmd = new SqlCommand(str, cn);
cmd.Parameters.AddWithValue("@username", TextBox1.Text);
cmd.Parameters.AddWithValue("@password", TextBox2.Text);
SqlDataReader dr = cmd.ExecuteReader();

if (dr.HasRows)
{
Session["username"] = TextBox1.Text;
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);


}
else
{
Label1.Visible = true;
Label1.Text = "Invalid Username/Password";
}
-------------------------------------------------------------------------------------
like that if iam checking authentication using dataset and sqldatareader how to use parameters?SqlConnection cn = new SqlConnection("user id=sa;password=abc;database=xyz; data source=server");
cn.Open();ds = new DataSet();
string str = "select username from security where username=@username, password=@password";da = new SqlDataAdapter(str, cn);  //how to pass parameters for that
da.Fill(ds, "security");
Response.Redirect("dafault2.aspx");

View 2 Replies View Related

Passing DDL Value To Bit Field In SQL

Jan 2, 2004

I have a DDL with two values: 0 and 1. When I use

sqlcommand.Parameters.Add(New SqlParameter("@fld", SqlDbType.Bit, 1))
sqlcommandl.Parameters("@fld").Value = System.Boolean.Parse(DropDownList1.SelectedValue)

or

sqlcommand.Parameters.Add(New SqlParameter("@fld", SqlDbType.Bit, 1))
sqlcommandl.Parameters("@fld").Value = System.Convert.ToBoolean(DropDownList1.SelectedValue)

to insert the selected value in a sql2k database BIT field I am given this error:

System.FormatException: String was not recognized as a valid Boolean.

How can I solve this problem?

View 1 Replies View Related







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