Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 14th, 2004, 05:29 AM
Authorized User
 
Join Date: Aug 2004
Location: Hull, yorkshire, United Kingdom.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Baby_programmer Send a message via MSN to Baby_programmer Send a message via Yahoo to Baby_programmer
Default sql query problem

hi!
Please help me i have a fuction that will check that, if there is any value exist in table
as input given.
the fuction i have written is like this but not working:

private int GetShopID(string ShopName)
{
    string connectionString = ConfigurationSettings.AppSettings["conStr"];
    string qry ="SELECT ShopID FROM tblShopInformation where ShopName=@ShopName";
    SqlConnection con= new SqlConnection(connectionString);
    SqlCommand cmd= new SqlCommand(qry,con);
    cmd.Parameters.Add("@ShopName",SqlDbType.NVarChar, 50).Value = ShopName;
    string Shop_ID=qry;
    int ShopID=Convert.ToInt16("Shop_ID");
    if(ShopID>=1)
    {
    Label1.Text="value exist";
    }
    return 0;
}


private void Page_Load(object sender, System.EventArgs e)
        {

            GetShopID("abc");
        }


If there is any other method to check the value in the sql table please
make this kind of fuction for me ..i'll be thankfull.

ashfaq
__________________
Baby Prgrammer
  #2 (permalink)  
Old October 14th, 2004, 07:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Dim bResult As Boolean = False
Dim objConn As New OleDbConnection(ConfigurationSettings.AppSettings( "conStr"))
Dim strSQL As String
Dim strTestValue As String
Dim objCommand As New OleDbCommand

objCommand.Connection = objConn
strSQL = String.Format("SELECT shopid FROM tblShopInformation WHERE (ShopName='{0}');", ShopName)
objCommand.CommandText = strSQL
objCommand.CommandType = CommandType.Text

objConn.Open()
strTestValue = CType(objCommand.ExecuteScalar, String)
objConn.Close()

If Not strTestValue Is Nothing Then
    If strTestValue = ShopName Then
        bResult = True

Sorry for the VB code.

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Query Problem mike.chary SQL Server 2005 1 September 26th, 2007 06:19 AM
SQL Query problem skarthikk SQL Server 2000 1 August 7th, 2006 02:20 AM
SQL query problem - Need Help Settt Biztalk 0 September 12th, 2005 09:32 AM
Problem in SQL query liorlankri ADO.NET 1 November 8th, 2004 12:37 AM
Sql Query Problem mateenmohd SQL Language 0 January 13th, 2004 05:31 AM



All times are GMT -4. The time now is 03:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.