|
1) rec = "select student_id from student_biodata where student_name = " + lstStudentName.Text + "";
2)string str = "select * from student_biodata where student_id = " + rec + "";
i want to get student_id first then i want to use id for specific record to display in data grid.
|
|
|
|
|
I assume this is homework and the fact that your code is not secure is not a problem ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
Read up on SQL injection attacks.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Try out this:
rec = "select student_id from student_biodata where student_name = '" + lstStudentName.Text + "'";
string str = "select * from student_biodata where student_id = " + rec + "";
OR
rec = "select student_id from student_biodata where student_name = '" + lstStudentName.Text + "'";
string str = "select * from student_biodata where student_id IN " + rec + "";
Reply me whether anypone of this worked or not
|
|
|
|
|
rec = "select student_id from student_biodata where student_name = " + lstStudentName.Text + "";
string str = "select * from student_biodata where student_id IN " + rec + "";
After this code their is an other error and where data adapter filling dataset
like this is the code
da.Fill(ds)
exception is on this line then it shows error message
Incorrect syntax near the keyword 'select'
Now what to do more ?
|
|
|
|
|
might be the problem is
rec = "select student_id from student_biodata where student_name = " + lstStudentName.Text + "";
string str = "select * from student_biodata where student_id IN =" + rec + "";
don't use IN as well as = together
and put quotes for student name field
Write it like this:
rec = "select student_id from student_biodata where student_name = '" + lstStudentName.Text + "'";
string str = "select * from student_biodata where student_id IN " + rec + "";
Reply me whether it works or not
modified on Wednesday, March 4, 2009 2:39 AM
|
|
|
|
|
Dear,
rec = "select student_id from student_biodata where student_name = " + lstStudentName.Text + "";
string str = "select * from student_biodata where student_id IN " + rec + "";
After this code their is an other error and where data adapter filling dataset
like this is the code
da.Fill(ds)
exception is on this line then it shows error message
Incorrect syntax near the keyword 'select'
Now what to do more ?
|
|
|
|
|
simply try adding single quotes for student name field
rec = "select student_id from student_biodata where student_name = '" + lstStudentName.Text + "'";
string str = "select * from student_biodata where student_id = " + rec + "";
OR
string str = "select * from student_biodata where student_id IN ( select student_id from student_biodata where student_name = '" + lstStudentName.Text + "')";
|
|
|
|
|
Dear,
Still i am not accessing acquired record with your this replay i am thankful i am getting records of two students one is in Class A and second is in Class B with same name like name is ABC in both classes, now i need only one record of selecting name in list box box with student id which is primary not with same name.
Thanks
Sajjad Ali
|
|
|
|
|
|
Catch the click and open a menu.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Yea. true.. But nowadays in from .Net 2.0 onwards i think we are having much more luxury.. that is to use a dropdown button control itself .. in this kind of situations.
I belive dropdown button is a part of Menustrip
|
|
|
|
|
Hi all,
Guys i have project for searching engine and the idea is connecting Google Desktop Search (GDS) with C# application i foud some helpfull code which search for a file and return its path like this code
using System;
using System.IO;
using System.Net;
using System.Xml;
using Microsoft.Win32;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class GDS
{
private string format = "&format=xml";
public GDS()
{
}
public ArrayList Search(string search, int num)
{
search = search.Replace(" ", "+");
WebClient localGDS = new WebClient();
string gdsResponse = null;
try
{
StreamReader sr = new StreamReader(localGDS.OpenRead(getSearchQuery() + search + format + "&num=" + num.ToString()));
gdsResponse = sr.ReadToEnd();
sr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
ArrayList ar = new ArrayList();
if (gdsResponse != null)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.LoadXml(gdsResponse);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
XmlNodeList resultsNode = xmlDoc.GetElementsByTagName("result");
foreach (XmlNode result in resultsNode)
{
XmlNodeList fields = result.ChildNodes;
Hashtable hash = new Hashtable();
foreach (XmlNode field in fields)
{
hash.Add(field.Name, field.InnerXml);
}
ar.Add(hash);
}
}
return ar;
}
public ArrayList SearchOnlyFiles(string search, int num)
{
search = search.Replace(" ", "+");
WebClient localGDS = new WebClient();
string gdsResponse = null;
try
{
StreamReader sr = new StreamReader(localGDS.OpenRead(getSearchQuery() + search + format + "&num=" + num.ToString() + "&flags=512"));
gdsResponse = sr.ReadToEnd();
sr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
ArrayList ar = new ArrayList();
if (gdsResponse != null)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.LoadXml(gdsResponse);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
XmlNodeList resultsNode = xmlDoc.GetElementsByTagName("result");
foreach (XmlNode result in resultsNode)
{
XmlNodeList fields = result.ChildNodes;
Hashtable hash = new Hashtable();
foreach (XmlNode field in fields)
{
hash.Add(field.Name, field.InnerXml);
}
ar.Add(hash);
}
}
return ar;
}
private string getSearchQuery()
{
RegistryKey currentUser = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, "");
RegistryKey searchUrl = currentUser.OpenSubKey("Software\\Google\\Google Desktop\\API");
object key = searchUrl.GetValue("search_url");
return key.ToString();
}
[STAThread]
static void Main(string[] args)
{
GDS gds = new GDS();
string words = "java";
ArrayList ar = gds.SearchOnlyFiles(words, 20);
if (ar != null)
{
foreach (object o in ar)
{
Hashtable hash = (Hashtable)o;
string category = (string)hash["category"];
if (category.Equals("file"))
{
Console.WriteLine("**********************************");
Console.WriteLine("File Found: " + (string)hash["url"]);
}
}
}
Console.ReadLine();
}
}
}
i did a complete project in java which search for a file and return many things like url,las_date_modified, and content but in c# i couldn't found a documintation talking about GDS and its ability to connect GDS API with C# application please if some interest or has usefull information for me please help...
|
|
|
|
|
This is java code ? If it's C# code, where did you get it from ? Why doesn't it work ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
No it is C# code but you have to donloade google dekstop search tool and install it in your machine
i am looking for some help to get solution for searching operation like i want C# code connect to GDS and give the result to user as interface
|
|
|
|
|
What is the way of displaying repeating multiple records and also grouping of that repeating records in HTML reports.
Earlier i was using Crystal reports and there was not at all any problem but due to some restrictions i am supposed to use HTML reports.
These multiple rows are saved in the database just i have to display it.
Help me as i am in a critical situation 
|
|
|
|
|
Tooo Basic .. Get familiar or atleast go through some Sql basic stuff.. I believe you have to use "GroupBy" and "Orderby" clauses Properly in your query
|
|
|
|
|
I think u did'nt get my question.
The best example to explain the issue is u go to any garment shop and purchased 4 different kind of shirts and atleast 2 sizes of each kind of shirt from that same shop.The shopkeeper gives u itemized bill.
In the database of that particular shop there would a normalized Item table to avoid repeat entries(as 1 CustomerID contains more than 1 record and that 1 record contains more than 1 sizes).
That cash memo that u get is a kind of report.
In the same way i need to display in that bill all the 4 shirts purchased with customerID which is not repeating and also "groupby" by each item to display each one's sizes respectively purchased and i.e in a HTML reports.
This is it.
Please give solutions for that
|
|
|
|
|
I am doing a project which is about
Generation of html to pdf (Encryption of MULTIPLE MARKED text included, PDF document must be at least 10 pages and encryption is to be done on each page)
I am using example: ID = 1 to encrypt the text
Can anyone help me as i do not understand how to use Itext for my project.
======================================================================================================
Is like the words that are encrypted in the HTML are being hidden.
After that, i need to generate it into a pdf.
example: This is an anple
After i encrypted "This is"
In the html file <encrypted ID = 1> This is </encrypted>
After it had been generate into pdf, it will show:
<<encrypted>> an apple
This can be done into multiple encryption (more than 1 page)
So how can i do this using Itext?
Itext: iText is a library that allows you to generate PDF files on the fly.
But how do i use it?
======================================================================================================
Thank you
modified on Wednesday, March 4, 2009 1:58 AM
|
|
|
|
|
What is itext ? If your html is encrypted, how can you expect to make it into a PDF ? Why MUST the PDF be 10 pages ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
I have a dataset that contains information froma database. The database has 3 columns named GlobalId, LocalId and Name. Basically the GlobalId is Autoincrimented and the LocalId is not. When I create an entry I want to check if there's a LocalId, if not then add a LocalId, if there is a LocalId then select the last one and incriment that number by 1.
My code looks like this at the moment:
private void GenerateEmployeeID()
{
int employeeID = 0;
DataTable dt = dsWBGTS.Tables["Person"];
if (dt.Rows[0][1].ToString() == "")
{
employeeID++;
lblLocalIdResult.Text = employeeID.ToString();
}
}
How can I retrieve the last number in the LocalId column and incriment that number by one?
Thank you!!
Illegal Operation
|
|
|
|
|
Well, for the local id to have meaning, it should always exist in the DB, shouldn't it ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
And that is why I am having this issue, because the method I am implimenting in my application should get the last LocalId entry from the dataset and incriment it by 1. The Dataset contains the latest information from the DB so obviously the LocalId will be relevant to the DB.
Illegal Operation
|
|
|
|
|
If your application has only one user, ever, then there's no issue with data traffic. So, ask the database. If your app has more than one user, then this approach is a disaster, so you need to ask the database to assign a number, and create the record, so the number doesn't get used twice.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|