Adding a default value to sql select parameters in vb.net

Hi,

    I know it's easy to select the default value if you use the sql data source object to configure your query and feed it the select parameters. However, i will like to know if it's possible or what's is the syntax to add a default value to sql query being executed before page is post back. Below is what i have so far: the text strikethrought is the missing piece i need help making it the default value.

Dim connect As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("Solution_DA_LiveConnectionString").ToString())

Dim sqlcommand As New System.Data.SqlClient.SqlCommand()

sqlcommand.CommandText = "web_getAllSubpns_mod"

sqlcommand.CommandType = CommandType.StoredProcedure

sqlcommand.Connection = connect

 

Dim dbpricelevel As New System.Data.SqlClient.SqlParameter

dbpricelevel.ParameterName = "@price_level"

dbpricelevel.Value = Session("price_level")

sqlcommand.Parameters.Add(dbpricelevel)

dbpricelevel.Value = DefaultSettingValueAttribute

 

Dim da As New System.Data.SqlClient.SqlDataAdapter

da.SelectCommand = sqlcommand

Dim ds As New DataSet()

connect.Open()

sqlcommand.ExecuteNonQuery()

da.Fill(ds)

 

0
penkye
4/14/2009 2:43:29 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

3 Replies
1430 Views

Similar Articles

[PageSpeed] 17

You can refer here

http://www.sqlservercentral.com/articles/Stored+Procedures/usingparameterswithstoredprocedures/2004/


MAKMark as Answer if this reply helps you
MVP ASP/ASP.Net
MVP ASP/ASP.Net
ASP.Net Hosting : Host DepotMy Site : ASPSnippets
0
mudassarkhan
4/14/2009 3:10:03 PM

Thanks for your link, i did review it and it's exaclty what i've done but my goal is to find if i can pass a default value to a parameter if there's no value available to it.

0
penkye
4/14/2009 6:09:50 PM

Simply pass the default value using parameters as you do in normal case


MAKMark as Answer if this reply helps you
MVP ASP/ASP.Net
MVP ASP/ASP.Net
ASP.Net Hosting : Host DepotMy Site : ASPSnippets
0
mudassarkhan
4/15/2009 5:11:11 AM
Reply:

Similar Artilces:

VB.net SQL Output parameter
Hi guys, hope that one of you may be able to help - I need to compare a value against a SQL output value, but I am having problems getting the SQL Output value into a textbox. Here is my code that I am using:Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cnn As SqlConnectionDim cmd As SqlCommandTryDim const1 As String = ConfigurationManager.ConnectionStrings("TestConnectionString").ToStringcnn = New SqlConnection(const1)cmd = New SqlCommand("AUW_SERVICE_MORD_S_TOTALWEIGHT", cnn)cmd.CommandType = Data.CommandTy...

Attach SQL DB to SQL Server 2005 using VB.Net
Is there any way to attach a SQL DB to SQL Server 2005 using VB.Net?  If so can you also set security? Can you rephrase your question? Attach SQL DB from which version of SQL server ? Look up books online for sp_attachdb and sp_detachdb.***********************Dinakar NethiLife is short. Enjoy it.*********************** I have a DB that was created in SQL Server 2005.  I have a website that displays data from systems all over the world.  Each system sends it's data to it's own DB.  The customer can then go to a website and see the data at real time.  What ...

Sql Server Script File(.sql) Execution by Vb.net Code
I have a problem. I m working on "light weight sql server"  project.   and i want to execute .sql file through vb.net code with the help of sqldmo library and sqlns namespace. but i donot know any method to directly execute the .sql file. i am successfully making the full script of select database of sql server.   please help me.... thanks.... Hi, You can use SQL-DMO object in your .net projects by referencing Sqldmo.dll  file which is in  C:\Program Files\Microsoft SQL Server\80\Tools\Binn  folder is default installation parameters are used. I...

SQL Server Reporting Services for SQL SERVER 2000 AND Visual Studio.NET 2005 .NET 2.0
Hi, Which version of SQl Server Reporting Services will work with SQL SERVER 2000 in pararrel with ASP.NET 2.0 (.NET 2.0 framework)?  Thanks, Azam HighOnCodingWanna get high! Hi, Okay I got the answer. Yes, we can use the SQL SERVER 2005 Reporting Services with SQL SERVER 2000. HighOnCodingWanna get high! ...

Store SQL return parameter in VB.NET variable
I am working with inserting customer complaints and want to get the complaint id back when the insert is complete.  So far I have the complaint being inserted without problem but I am not getting the complaint id back in the program. SQL Insert procedure:ALTER PROCEDURE [dbo].[InsertComplaint] @fcomp_assign CHAR(30), @fcomp_bu CHAR(25), -- required @fcomp_cntct_id SMALLINT, -- required @fcomp_create_by CHAR(30), -- required @fcomp_cust CHAR(8), -- required @fcomp_desc CHAR(8000), -- required @fcomp_ftr BIT, -- required @fcomp_inv CHAR(8), @fcomp_mor CHA...

Sql Parameter array converting from VB.net to C#
I have some code in VB.net which I use to create an array of parameters to use in my stored procedures.             Dim cmdParameter(0 To 1) As SqlParameter            cmdParameter(0) = New SqlParameter("@minDate", SqlDbType.NVarChar)            cmdParameter(0).Value = minDate This creates two parameters and works perfectly. However, when I put it through an online code converter to go to c# (I have to recode my web...

Importing MS Project Values into VB.Net for SQL?
Hi guys, When it comes to .Net I'm a complete newbie (despite studying an analysis degree and having a tutor who can't program at all, I'm expected to create a working ASP.Net application!). What I'm attempting to do is create an application that will allow the importing of data from an MS Project file, storing some particular values in a MS SQL database and displaying those on screen. What I envisage is that a person specifies where the Project file is (click browse, select location). It then imports the related data. Specifically the data will be milestones and whether or not are on ...

retrieve selected data from SQL database using vb.net
I already watch the video in the vb.net express to learn about the data binding. But the problem that i face is when i want to retrieve certain data from the database. the video just show how to fill and update. who ever know the code to retrieve the selected row from the SQL database using vb.net 2005????? thanks do u want to retrive a particular cell or a particular row from the database?what control do you want to bind the retrived value to? thanks Imran NathaniLet the game begin!!Barcode image generation made easy.Writing an ActiveX Control in C#Generating Relational Data From XML D...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

VB.Net; SQL
Hi there! I only recently started using ASP.Net. I really appreciate the fact that i now can cleanly seperate code from presentation. This is the best thing in the world ever! There is a problem however... Visual Basic. I have never used it before. Only VBscript. Communicating with my Database tunred into a nightmare overnight! Could somebody PLEASE suggest some book or tutorial or something to help me out. I need to write complex tSQL strings but i cant seem to come right. MySQL did release in their manual a full help section on writing SQL strings for their dat...

VB.NET SQL stored procedure: procedure has no parameters and arguments were supplied
VB.NET SQL stored procedure: procedure has no parameters and arguments were supplied Please assist me:This erorr message is produce when calling the stored procedure in vb.netProcedure AutomateMatterNumber has no parameters and arguments were supplied."MS SQL 2000stored procedure:*/CREATE PROCEDURE dbo.AutomateMatterNumber ASDECLARE @nextMtr AS BIGINTDECLARE @dtToday AS DATETIMEIF NOT EXISTS(SELECT * FROM tempMatter WHERE DATEDIFF(dd,DateSet,GETDATE())=0 )BEGINDELETE FROM tempMatter-- incase there are some old recordsSELECT TOP 1 @nextMtr= CONVERT(BIGINT, MatterNumber) + 1 ,@dtTod...

Trying to access SQL data with session value (I'm a total newb to VB and .Net 2.0)
I'm not an expert programmer in any way shape or form but I'm working on my next project and need some assistance. We have an existing site that is up and been running for a couple years and needs an uplift to asp .net 2.0. All our data is in a SQL 2005 db and is accessed by 3 groups, administrators, techs and clients. Admin see all data and all functions, Techs only see their calls and clients only see their data but some clients have 20 users. Our SQL db uses a field named accounID to tied multiple accounts together. On our old site once a user logged on a session was cre...

adding sql parameter in VB
I have a details view with several parameters set up in my asp.net 2.0 code, I want to add a parameter before the sql parameter is executed. I need to use the find control of the details view because I am using items/edit item templates in my details view control. I tried this(see below) as well as the detailsview item command event args to no avail. It doesn't see the other parameters that have already been declared in my asp.net code. I don't want to have to declare all my varibles that are already in my asp.net code. I just want to add another parameter.  Sub InsertNew(ByVal ...

Adding values in vb.net
Hi, Can anyone please help me. I have 5 text boxes which will be used to enter values in them. And i have a label control that will be displaying the total value entered in these 5 text boxes. I know we used to use javascript to add all these values dynamically. I mean, as soon as you enter a value in the 1st text box and leave that box, it will update the label control with the new value. I want to do the same logic without using javascript in vb.net. Has anyone done this before. Can anyone please help me with this. Can anyone give me an idea, so that i can proceed. Any help will ...

Web resources about - Adding a default value to sql select parameters in vb.net - asp.net.sql-datasource

Parameter - Wikipedia, the free encyclopedia
A parameter (from the Ancient Greek παρά , "para", meaning "beside, subsidiary" and μέτρον , "metron", meaning "measure"), in its common meaning, ...

fb_source Parameter - Facebook-Entwickler
This document lists the complete list of values for the fb_source parameter that is returned with th...

Google / Firefox Parameter - Flickr - Photo Sharing!
HS what? www.seroundtable.com/archives/017105.html

Cat 8: TIA performance standards committee chairman previews parameters of forthcoming twisted-pair cable ...
Category 8, the next-generation twisted-pair cabling specification, is still in development, but the outlook looks quite positive that it will ...

Philippine president asks for 'parameters' of Mayon Volcano tours
Philippine president asks for 'parameters' of Mayon Volcano tours People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, Apr, May, ...

Alternatives to boolean parameters
... ) { PrintLine ( item . Name ); if ( printDetails ) { PrintLine ( item . Description ); } } } Aha! Now can see that the boolean parameter ...

Exporting Error (Error in Parameter...: Apple Support Communities
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability ...

Apple tech monitors device aging, adjusts operating parameters to ensure optimal performance
... describing a method of monitoring the aging of a device's electronics, comparing the data with a global average and modifying operating parameters ...

Is it poor programming practice to pass parameters as objects?
... a free, community-powered network of 100+ Q&A sites . Risser asked: So, we've got a guy who likes to write methods that take Objects as parameters, ...

Parameter Short Film Competition sponsored by Grolsch
Grolsch presents Parameter The A.V. Club Short Film Competition Please Enter Your Date of Birth Ineligible entry Enter For people over the age ...

Resources last updated: 1/22/2016 10:43:48 PM