How can i pass a string variable from code behind page to html page on event fire. i want to pass sql qerry to SelectCommand (SELECT * FROM [Tickets] WHERE ([TicketNo] = @TicketNo)) in some variable from codebehind on some event fire.
Hi Folks, i am trying to add a connection string value to my client side as follows. i am getting error. any ideas?? <asp:SqlDataSource ID="SqldsComments2" runat="server" ConnectionString='<% session("sqlConn") %>' SelectCommand="SELECT * FROM TicketComments Where TicketNo=@TicketNo "> <SelectParameters> <asp:Parameter Name="TicketNo" DefaultValue="0" Type="string" /> </SelectParameters> </asp:SqlDataSource>
Hi guys, Here is the html string that I want to transfer it to another variable so, I can post it to my sql server database <span style=""font: 12px arial; color : #000000; text-decoration : none;""><br>MODEL- USB01000C01CL VENDOR- ACTIONTEC ELECTRONICS<br> <br>FEATURES- VoSKY Chatterbox for Skype<br> Plug-and-Play Speakerphone for Skype!<br> VoSKY Chatterbox from Actiontec is the go-anywhere speakerphone <br> solution for Skype! No software or special drivers required. Simply <br> plug your VoSKY Chatterbox into any computer and you are ready to <br> start talking! <br> Make Skype Calls on a Speakerphone Plug Chatterbox into your <br> computer, and make or receive a Skype call as you normally would. <br> Then talk to your Skype contacts, hands-free and without wearing <br> headsets! <br> You do not need to download any additional drivers or software. Just<br> take Chatterbox, plug it into any computer, and you are ready to <br> go! <br> Chatterbox offers superb sound quality with the latest technology in<br> full duplex audio, DSP-enhanced sound quality, and echo <br> cancellation. <br>* Verified by and certified for Skype <br>* Replaces your headset/microphone <br>* Small, lightweight device goes anywhere you go <br>* Full duplex speakerphone with adjustable volume and mute control <br>* DSP-enhanced sound quality <br> <br> -- SPECIFICATIONs ------------------------------------<br>CONNECTORs - (1) USB 2.0/1.1 port<br> (1) 2.5mm Headset Jack<br>INDICATORS - LEDs for Ready, Microphone Mute<br>FUNCTION KEYS- Volume Up, Volume Down, Microphone Mute <br>SPEAKER - 1w peak, 40 mm, 4 ohm, 120 Hz to 6 KHz, 120 dB <br>MICROPHONE - Voice pick-up range up to 4 meters <br>APPROVALS - FCC, CE<br>REQUIREMENTS - PC running Windows 2000/XP with one available USB port. <br>DIMENSIONS - 7.7cm x 5.8cm x 2.1cm WT. 50 grams<br> <br><br>MANUFACTURER WARRANTY: 1 YEAR</span>
however If I just do; dim myvariable as string = htmlvalueatabove after importing the myvariable value to the sqlserver my asp.net detailview control only able to show only first 17 letters . Up until "fo" I am sorry if I am not able to provide you clear question. I am so frastrated at the moment, after 6 coffie and 2 minutes bathroom break I can't write anymore. I will shutup and wait for one you and respond.
We have a "Comment" field that is saved as a HTML string to the DB. This field needs to be pulled into a report as rendered HTML.
I know this has been hashed out before, but has anybody found a good solution in the past couple of months?
We are thinking about storing two versions of the Comment in the DB: one with HTML, one as simple text. Has anybody found this an acceptable solution? I know it flies in the face of good DB design, but it seems the quickest, easiest solution...
Any word if this will be fixed in the next major release of SSRS? Can we expect this release any time soon?
I am trying to do string scrubbing in a sql clr function, including removing certain HTML formatting. I would like to use HtmlDecode method, but it's my understanding that System.Web is not available for Sql Clr (without marking code unsafe - not an option for me as this is for an application we sell externally, and unsafe calls woudl not go over well with customers). Is there any class that IS supported for Sql Clr that exposes this functionality? Thanks.
I have a flat text file with lots HTML tags and corresponding values
For example <Near_Side> 5563 </Near_Side> <Top_Down_Code> Xe345 <Top_Down_Code>
So, For example I can use the a function
ALTER function dbo.StripHTML( @text varchar(max) ) returns varchar(max) as begin declare @textXML xml declare @result varchar(max) set @textXML = REPLACE( @text, '&', '' );
[Code] ...
To which Select dbo.StripHTML('<Near_Side> 5563 </Near_Side>') Value
I'll get 5563
However how would you get the values within the tag itself ? E.g.
Value Name 5563 Near_side Xe345 Top_Down_Code
I was thinking along the Charindex but cant seem to get it right.
I am retrieving a field from SQL and displaying that data on a web page. The data contains a mixture of text and html codes, like this "<b>test</b>". But rather than displaying the word test in bold, it is displaying the entire sting as text. How do I get it to treat the HTML as HTML?
Lets say I have a Sqldatasource that uses the following SelectCommand="SELECT category,name FROM table". How do I get the value on category from my datasource in code behind if I know that my selectcommand always will return one row? Can I write something like datasource.items["category"].Value? Thanks for your help!
hi to all,i am kinda crazy now... i have this problem regarding codebehind codes... i am kinda still a beginner...can you please give me an example of codebehind codes in which selectcommand (and other commands) in sqldatasource to be written in aspx.vb not on aspx..on how to execute it and so as its parameters...i know that those commands are easy to configure on aspx page... but there some reasons why i need to put it in aspx.vb page... so is there any way...? is my problem clear?hoping for a reply asap.. thank you...
I am trying to use the SQLDataSource from the codebehind. However, I have a problem accessting the ConnectionString.I declare my connection string in my web.config file, and I declare this as:Dim DBConn As New SqlConnection(ConfigurationManager.ConnectionStrings("DbConnString").ConnectionString)My problem arises though when I get to the SQLDataSource. How can I reference DBConn via the SQLDataSource.ConnectionString?Karls
Hi, I have a SQLDataSource, button, textbox, and label. I take the text from the textbox, count it's occurance in the database, then assign the number to the label. The code works but I would like to provide a button that will execute/invoke the SQLDataSource. I have this in the click event for the button: Me.label1.Text = SqlDataSource1.Select(DataSourceSelectArguments.Empty) How do I execute a SQLDataSource from the code-behind for the button click event? Thanks.
Hello...Can someone help me?I´m getting info of a product via sqldatasource in this way:<asp:SqlDataSource ID="myData" runat="server" ConnectionString="..." SelectCommand="spGetProduct" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:QueryStringParameter Name="Id" QueryStringField="Id" Type="String" /> </SelectParameters></asp:SqlDataSource>In my ASPX page I get the data in this way:<asp:Repeater ID="repProduct" runat="server" DataSourceID="myData"> <ItemTemplate> <p><%# Eval ( "ProductName") %></p> </ItemTemplate></asp:Repeater> My problem is in my code behind because I need some data from this DataSource.For example, I want the Product Name as the page title. So the question is how I get something like this in my code behind:protected void Page_Load ( object sender, EventArgs e ){ this.Page.Title = Eval ( "ProductName") ;}Thanks!
Hi, I don't know if i's a silly question. Now I want to get data from sqldatasource by only write some code,I don't know without creat some data control components if it can be true? If it can do,how can I write the codes? Especially I don't know how to write the code witch can "read" data.
Hey All, I'm very new to ASP.NET and have recently begun using the databinding functionality. So far, all I've had to do is drag and drop the various controls and then use the data source wizard to set up an appropriate query. However, now I've got a bit of a different need. In the VB codebehind, i need to be able to ask whether something is true in the database, and then if it is, carry out functions. So, for example, what I need to do is: if (SQLStatement "Select charttype FROM charts WHERE datasource = " & dropdownlist1.selecteditem.tostring()) Then 'do whatever end if Trouble is, I don't know how I would go about binding the data so that I could access it in this way. Any guidance would be very much appreciated. Thanks,J Rankin
This is probably an easy one. What is best way to determine if a SqlDataSource is empty (i.e. the query produced no results) in the CodeBehind? I'm using this: if (SqlDataSource1.SelectCommand.Contains(String.Empty)) { //Add code for scenario here. } It seems to work, but something just doesn't feel right about it for some reason. Thanks
Does anyone know what is the maximum size for a string variable that can be used by Execute statement in SQL 7 and SQL 6.5? If I really need to execute a long statement around 9000 characters long, how can I do it?
declare lcsql varchar(x) && what is the maximum size for x in SQL 7 and SQL 6.5
hi there, i am trying to pass a string which contains a string, here is the code which is wrong : {string sqlcommand = "select pnia.pnia_number, pnia.user_name, pnia.date_pnia, pnia.user_pnia, problem.problem, gormim.gorem_name, status.status_name from pnia,gormim,problem,status where (pnia.status='@p1' and status.status='@p1' and pnia.problem=problem.problem_num and pnia.gorem=gormim.gorem)"; OleDbCommand cmd = new OleDbCommand(sqlcommand,con);OleDbParameter p1 = new OleDbParameter("@p1",this.DropDownList4.SelectedItem.Value.ToString()); cmd.Parameters.Add(p1); } the problem is that the sql compailer doesnt take the parameter (@p1) as a string if someone could help me with that it would be great ! tnx
Using SQL Server 7.0, I am trying to use a variable string called from a form to perform a simple query.
Here's what it looks like:
[after submitting a form on the previous page with a drop down list box titled "fiscal"]
dim strYear
strYear = Request.Form("fiscal")
sql = "SELECT * FROM VENDOR WHERE STATUS = 'P' AND '"& strYear &"';"
[where strYear is the following: PYMNT_DT > ''12/31/98'']
Records exist that meet this criteria. If the PYMNT_DT > '12/31/98' is hardcoded into the sql statement, 12 records are returned. However, when the variable string is used instead, no records are found. Any ideas on how this problem might be fixed?
Declare@Testnames as Varchar(500) Set@Testnames = ('CT,MRI')-- List all radiology type SELECT* FROMRPT_OUTPATIENT_IMAGING WHEREservice_level2 In (@Testnames)
Nothing comes back.
When I run:
SELECT* FROMRPT_OUTPATIENT_IMAGING WHEREservice_level2 In ('CT','MRI')
Is there a way around the character limit for a variable? I'm throwing the following in a variable and evaulating it as an expression and having an execute sql task do it, but I can clearly see it's being cut off.
I have a database with columnsuserOwnListsuserID uniqueidentifieruserName nvarchar100userList nvrachar100createdDateI have created successfully a gridview controller to edit these values in database. The Gridview data is populated by SqlDataSource.I have also created a EmptyDataTemplate and created a form into it. There is only one textBox and submit button to create the First entry to userOwnLists -table.Now I collect the value from EmptyDataTemplate textbox with id userList1 and create a codebehind logic for the submitbutton.protected void Button2_Click(object sender, EventArgs e) { TextBox listName = (TextBox)this.FindControl("listName1", GridView1.Controls);SqlDataSource1.InsertParameters["userId"].DefaultValue = Membership.GetUser().ProviderUserKey; SqlDataSource1.InsertParameters["userName"].DefaultValue = Membership.GetUser().UserName.ToString(); SqlDataSource1.InsertParameters["listName"].DefaultValue = listName.Text; SqlDataSource1.InsertParameters["createdDate"].DefaultValue = DateTime.Now.ToString(); SqlDataSource1.Insert(); }The problem is now that I get error: Exception Details: System.Data.SqlClient.SqlException: Implicit conversion from data type sql_variant to uniqueidentifier is not allowed. Use the CONVERT function to run this query.OK. So I Googled a bit and found this:http://scottonwriting.net/sowblog/posts/4690.aspxMy Question is: How do I convert userId so I can insert it to database successfully?This does not work:String userId = Membership.GetUser().ProviderUserKey.ToString(); SqlDataSource1.InsertParameters["userId"].DefaultValue = Convert.ToString(userId);
i have string variable as, String str="Int"; now, while assigning sql parameters, i want param.SqlDBType=SqlDBType.Int; but, value of Int is dynamic. it may be string or double so, i want it to be as, param.SqlDBType=(SqlDBType)str; but its not acceptable(its invalid cast). in any way can i do it and how? regards---
I'm trying to add a 'change password' control to my site and seem to be having some issues. I have code that works if I statically define what user is displayed on the form, but I cant get it to detect the 'authenticated' user and show them the reset for for that ID.If I take the "+ myid" out of the select statement and just define the username statically the form works properly. Error:System.Data.SqlClient.SqlException: The column prefix 'System.Security.Principal' does not match with a table name or alias name used in the query. Here's a piece of the code that is supposed to detect the current logged in user. However, it gives the error. (some of the code may be redundant but its not causing issues that I can tell) public void InitPage() { IPrincipal p = HttpContext.Current.User; String myid = HttpContext.Current.User.ToString(); SqlServer sqlServer = new SqlServer(Util.SqlConnectionString()); DataTable dt; SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString); SqlDataAdapter cmd1 = new SqlDataAdapter("select * from USER WHERE USER_NAME = "+ myid, cnn); DataTable UIDtable = new DataTable(); cmd1.Fill(UIDtable); User_Id.Value = UIDtable.Rows[0]["ID"].ToString(); dt = sqlServer.USER_SELECT(Util.SiteURL(Request.QueryString["Pg"].ToString()), User_Id.Value);
I want to declare a variable that will serve as my where clause. The variable will be passed in from our website. Does anyone have any information or can guide me in the right direction to do this?
example:
@variable varchar(1000)
SELECT * FROM table WHERE @variable
(The @variable would reflect the where clause string)
I'm trying to write a stored procedure in SQL that will make a copy of a file and then append the current date to the end of the copy's filename. I'm storing the date in a variable called @currentdate which is defined as:
Hi,I am having problems setting the value of a variable in a SQL Stringthat I have to create dynamically in my procedure. The code that Icurrently have is as follows:set @sqlStatement='Set @compare_string=' + '(Select ' +@group_column_list_mod + ' from ' + @Tbl_Name + '_Sorted' + ' whereIdentity_Column=' + ltrim(rtrim(str(@loop_counter))) + ')'exec(@sqlStatement)The error message that I get is as follows:Must declare the variable '@compare_string'.Here @compare_string has already been declared in the procedure and Idon't have a problem using the variable anywhere else but this SQLStatement (when called using the EXEC function).I am not sure why SQL Server can't see the variable declared when usedin a string in conjunction with EXEC. Is this a syntax issue? Any helpon this issue would be greatly appreciated!Thanks in advance.
I have to send an email using a variable as message body... the variable gets its value from database varchar(8000). Due to limited size of string variable in SSIS the value gets truncated.