Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

Tuesday, March 20, 2012

Asterisk in SQL

I'm trying to creat a search form and want to use the Like clause in my select statement so that a user can enter part of a word rather than the entire word. When I use this sql I get no results:

SELECT DISTINCT Keyword.CodeID FROM Keyword INNER JOIN Code ON Keyword.CodeID = Code.CodeID WHERE ((Keyword.Keyword)Like '*ARR*'AND (Code.ProgLang)='VB.NET') ORDER BY Keyword.CodeID

The problem is with the * . If I remove the * it works fine. If I use the code within Access rather than from my aspx code, it works fine. Is there a work around for this?

Hi,

% (percent) is the standard wildcard character. Access client does support *, but when you use it via OleDB (Jet provider) it also requires %.

Therefore put

SELECT DISTINCT Keyword.CodeID FROM Keyword INNER JOIN Code ON Keyword.CodeID = Code.CodeID WHERE ((Keyword.Keyword)Like '%ARR%'AND (Code.ProgLang)='VB.NET') ORDER BY Keyword.CodeID

|||That did it. Thanks!!!

Monday, March 19, 2012

assigning values to parameters dynamically

i using a bound data grid which is using a stored proc. The stored proc needs the ClientID "if logged in" there is no form or control on the page outside of the loginstatus. I am wanting to pass theMembership.GetUser.ProviderUserKey.ToString() to the asp:parameter but I cant get it to work.

So How do I pass a variable to a stored proc parameter using a bound data grid.

I this its very strange that this cant be dont and there are a raft of reason why you wold want to do this with out the need to pass it to a form control.

please help

jim

Add the parameter to you parameters collection as a normal asp:parameter, then hook up to the data-source control's Inserting/Updating evnet (I assume you use a data-source control with the grid) and use the event argument to get access to the command object's parameters collection (if you use SqlDataSource), or the InputParameters if you use the ObjectDataSource.|||Or alternatively, when the user authenticates, store their id in a session variable, then anywhere in your app you can add it as a session parameter.

Sunday, March 11, 2012

Assigning one text box value to the other text box in the sql reporting services Form

Hi,

Can some one help me in this case,

I am manipulating a value for onetext.value , And I want to assign like this

seconetext.value = onetext.value in the SQl reporting services form,

Is it possible? if so can any one help me with the syntax?

-Thanks

Yes, this is possible.

In "seconetext", use this expression:

=ReportItems!onetext.Value

-Chris

Thursday, February 16, 2012

ASP.net with SQL issue

I have to develop asp.net application, which reads data from SQL database and insert data into SQL database. Basically I have to create asp.net form . Please can anyone tell me how do I start from scratch. Thank you.Beyond advising you you use stored procedures instead of inline SQL, and to use ADO.NET, you really should be asking this question in one of the VB.NET forums.

asp.net want to make SQL time format of 00:00:00:000 to 14:42:51:153 when inserting in dat

I have asp.net 1.1 web form and it inserts date and time in SQL database, but it insert only date not time , It insert date time in following format

2002-01-22 00:00:00.000

some one tell me why it is not inserting time or why it is inserting time as 00:00:00:000.

I want to my time to look like 14:42:51:153. (format)

How can I change my time format

give me asp.net codes for time formating or what do I need to do to resolve the problem,

thank you

maxmax

I think your application is not sending the date properly. Do a response.write of the value you are sending to the db and verify.

Monday, February 13, 2012

ASP.NET mini Form with SQL Server 2000

Hi, i have created a mini form to test out easy steps and my sqlconnection but something is wrong with my connection i think...
I am running windows XP Pro SP 2. i have Microsoft VisStudio .NET 2003fully installed and now im installing SQL Server 2000 DeveloprsEdition. I just cimpleted the installaion and picked some settings:
Local Computer Installation, Create new Instance since this is thefirst time i use it, Server and Client Tools, and chose a Local ratherthe Domain option aferwards. (i have used this version before but hadto format the comp so now reinstalling everything).
My problem is this, i basically started the server and it on online. iwent to the "enterprise manager" and in the "Microsoft SQL Servers-> SQWL Server Group -> (Local)(Windows NT)-> Databases, icreated a new database called tables and added a single table just tobegin testing to see if at least its functional. i was able to do thisso far.
Now i started my .NET, and wrote a tiny program to see if theconnection to the SQL database would open, but it didnt. It alwaysfailed. i am programming an ASP.NET WebApplication. I cant open theconnection to my database. i dont know why. (The tiny piece of code iwrote is at the bottom in case you know c#). There is a note alsounder the code for the ones who will read through its simlicity
any help or walk through would be appreciated. thank u...
Sam



CODE:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
namespace WebTest1
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
string connection = ConfigurationSettings.AppSettings["ConnectionString"];


protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.Label outputBox;
protected System.Web.UI.WebControls.Label Label3;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
outputBox.Text = "Button has been clicked";
SqlConnection conn = new SqlConnection(connection);

outputBox.Text += "------Creating sql Connection";

try
{
conn.Open();
outputBox.Text += "-----opening the Connection";
}
catch(Exception p)
{
outputBox.Text += "-----failed to open Connection";
Console.WriteLine(p.ToString());
}
outputBox.Text += "----Success Connection and Login to Server!";

}
}
}


NOTE: i always get this output :
Button has been clicked------Creating sqlConnection-----failed to open Connection----SuccessConnection and Login to Server!
it skips the try block's print line which means it didnt work.....

string connection =ConfigurationSettings.AppSettings["ConnectionString"]; this one iupdated in my Web.config and included application setting line thatloox like this
<add key="ConnectionString" value="Data Source=127.0.0.1; Initial Catalog=login; User Id=sa; password=pass" />

You don't say what the error message is. Probably because you are catching it and not dealling with it. In your catch block you should output the p.Message to the outputBox for debugging purposes - Writing that to the console is not going to do any good as there isn't a Console.

You said you created a database called "tables". But your connection string is attempting to open a database called "login". If you do not have a database called "login" then the connection will fail.
I've never attempted to set the datasource to "127.0.0.1" before, so I cannot say if that is likely to be a problem. If I am connecting to the SQL Server on the local machine I always use "(local)"
Does this help?

|||

swy000 wrote:


string connection = ConfigurationSettings.AppSettings["ConnectionString"]; this one i updated in my Web.config and included application setting line that loox like this
<add key="ConnectionString" value="Data Source=127.0.0.1; Initial Catalog=login; User Id=sa; password=pass" />


I am not sure why you are using the loopback IP address 127.0.0.1 in your connection string when you can just use local host. In C# check out Programming .NET by Jeff Prosise for good sample code for Asp.net and the book written by the people who write the code for this site Coding strategies of the Asp.net team by Rob Howard and mathew Gibbs, for sample code for web applications in C#. Try the link below for sample connection strings. Hope this helps.
http://www.connectionstrings.com/