|
|
|
Junior Member
      
Group: Forum Members
Last Login: 3/3/2007 6:14:43 AM
Posts: 16,
Visits: 12
|
|
Hi,
I am trying to query a database for 2 conditions but I can't get the query to work.
Can anybody see a problem with this line of code?strQuery="SELECT Count(*) AS intTotal FROM tbl_artists WHERE fld_artist_name = '" & strReqname & "'" "AND fld_user_id ='"& strUsername & "'",objConn,,,adCMDText
objRS.Open strQuery,objConn,,,adCMDText
numRecords = objRS("intTotal")
|
|
|
|
|
Forum Member
      
Group: Forum Members
Last Login: 2/8/2007 8:41:42 AM
Posts: 45,
Visits: 35
|
|
Try thisstrQuery="SELECT Count(*) AS intTotal FROM tbl_artists WHERE fld_artist_name = '" & strReqname & "' AND fld_user_id ='"& strUsername & "'"
|
|
|
|
|
Junior Member
      
Group: Forum Members
Last Login: 5/24/2007 6:06:56 PM
Posts: 13,
Visits: 1
|
|
|
|
|
|
Forum Newbie
      
Group: Forum Members
Last Login: 1/3/2008 3:34:05 PM
Posts: 6,
Visits: 4
|
|
Yeah. That kind of looks like you cut and paste something into your code without knowing what it is or what it does.
That's a dangerous thing - especially when messin' with SQL statements. Besides, you really need to learn the SQLCommand object:
SqlCommand cmd = new SqlCommand("Select * From Categories Order By Category", new SqlConnection(ConfigurationManager.AppSettings["connString"]));
cmd.Connection.Open();
DataList1.DataSource = cmd.ExecuteReader();
DataList1.DataBind();
cmd.Connection.Close();
cmd.Connection.Dispose();
Where your connection string is held in the AppSettings in your Web Config file.
That's the way to do it.
dRunkenMOnkey
|
|
|
|