|
|
i hav written following code for login page..
SqlConnection con=new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=MLM;Integrated Security=True");
SqlCommand com=new SqlCommand("select UserName,Login_Password from RegistrationForm",con);
con.Open();
SqlDataReader rs = com.ExecuteReader();
while (rs.Read())
{
if ((rs[0].ToString() == T1.Text) && (rs[31].ToString()== T2.Text))
{
string s1 = T1.Text;
Response.Redirect("HOME.aspx?UserName=" + s1);
return;
}
else
{
Response.Write("Unsuccessful Login");
T2.Text = "";
T2.Focus();
}
}
rs.Close();
com.ExecuteNonQuery();
con.Close();
bt the error occured is Array index out of bound....bt when i take rs[1] instead of rs[31],then error is like unsuccessful login
|
|
|
|
|
manjusha s wrote: .bt when i take rs[1] instead of rs[31],then error is like unsuccessful login
Well, that's what your code is supposed to say when you type a wrong password. This is what happens, whit rs[2];
Here you check whether username and password combination are present in the database
if ((rs[0].ToString() == T1.Text) && (rs[31].ToString()== T2.Text)) If they don't exist, then the computer will execute the else-part;
else
{
Response.Write("Unsuccessful Login");
T2.Text = "";
T2.Focus();
} There is your message. Shouldn't happen when you use a password that is in the database.
Now, when you simply change the number of the index to 31, your code becomes broken; there aren't 31 fields in that query, so it tries to read from memory that ain't there.
select UserName,Login_Password from RegistrationForm returns two fields, not 31.
I are troll
|
|
|
|
|
your code is good and validate user and password but is not optimazed.
exception occered in
if ((rs[0].ToString() == T1.Text) && (rs[31].ToString()== T2.Text))
because in your query you select only two columns from table
and sql server return two selected columns but use number 31 for index.
when you read data by SqlDataReader you can use indexed mode
sqlDataReader[item index]
item index must one less from columns count or one less from sqlDataReader.FieldCount
to solve your problem change your if to
if ((rs[0].ToString() == T1.Text) && (rs[1].ToString()== T2.Text))
for indexing item in datareader and dataset it not importent how many columns is in table it importent how many columns are selected in query
|
|
|
|
|
Hello everyone ,
I have an issue i.e, I am using crystal report(version 11 release 2) in my windows applications developed in vb.net (2005)and sql server(2005) as backend . In one of the forms i placed one reportviewer control,
crystal report taking long time for preview & print(nearly 2 minute) .
please any one help me to getout of this
Dim rpt As New CrystalReport1() 'The report you created.
Dim myConnection As SqlConnection
Dim MyCommand As New SqlCommand()
Dim myDA As New SqlDataAdapter()
Dim myDS As New Dataset1() 'The DataSet you created.
Try
myConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;" & _
"Initial Catalog=northwind;")
MyCommand.Connection = myConnection
MyCommand.CommandText = "SELECT * FROM Customers where cid=10"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "Customers")
rpt.SetDataSource(myDS)
CrystalReportViewer1.ReportSource = rpt
Catch Excep As Exception
MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
I asked This Question Already but No one ready solve my Problem.
Please tell how to increase My Crystal report Preview ? My staff scolding me. please
Advance thnx.
|
|
|
|
|
First, try the samples that come with CR; you'll notice that these aren't speedmonsters either. CR has lots of features, and they all take time to load. I'm hoping that they'll soon release some lightweight version.
Also, check your query, things like indexes. Measure how much time it takes to execute that query. CR won't be faster than the server.
Last, try preloading as much as you can. Perhaps you could move the loading of the query to the initialization of the form, in a backgroundworker. It doesn't save much time, but it might be just enough.
I are troll
|
|
|
|
|
What is .net compact? How difference between .net framwork?
|
|
|
|
|
xingselex wrote: What is .net compact?
A subset of the .NET framework. There's not enough room for the entire .NET Framework on a mobile device, so they created a compact edition for Windows Mobile. You can read more about it here[^].
xingselex wrote: How difference between .net framwork?
It offers less functionality than it's big brother.
I are troll
|
|
|
|
|
Hi,
I want the steps or creating store procedures....and it should be written
|
|
|
|
|
1. Stored procedures have absolutely zero to do with the .NET framework. You should have asked this in the database forum.
2. You need to identify what database the stored procedure is for. Each DB has it's own unique syntax for stored procedures.
3. You could get the answer quicker just by googling for create stored procedure with the DB identified above.
4. The steps for creating stored procedures normally involve using a text editor, of some description, a design and some tables.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
Hi All,
I have a situation where I need to do some custom message filtering.
Unfortunately I need more functionality than provided by the
IMessageFilter system or by overriding a Form's wndproc() method.
What I need is to be able to run code before and after a message is
processed and optionally drop selected messages.
As I understand it:
The IMessageFilter system only allows filtering out selected messages
(can't run code after they have been processed)
A Form's wndproc method only sees messages destined for that form. (I
need to handle all messages for the entire application)
In an unmanaged application say in visual c++ it would be a simple
matter of implementing ones own getmessage/dispatchmessage loop. In
the dotnet framework the actual message loop is implemented in native
code and is inaccessible to the programmer.
Does anyone know a solution for this?
Regards,
Felix
|
|
|
|
|
Unfortunately, the only thing you can do outside the form is use Application.AddMessageFilter to add your own filter, and (as you've surmised), this only works on capturing a message before it is dispatched to the window. What you could possibly do (and this would be one heck of a hack), is use a combination of AddMessageFilter and a Mediator to control what happens. What you'd do is hook into the WndProc of each form, and pass the details to the mediator to work out whether or not the message could be processed.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks for your answer. I think I may have to add a custom BaseForm class that overrides the wndproc and which all of my Forms inherit from. That way I could insert global message processing which would be similar to writing a custom message loop.
|
|
|
|
|
Keep in mind existing dialogs (OpenFileDialog, MessageBox, ...) will not inherit from your BaseForm, so while one of those is open, your special message handling will not occur automatically.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Yeah, it is not ideal.
As there seem to be so many helpful knowledgeable people on here, I'll describe the actual problem I'm trying to solve and see if there are any other ideas.
The problem I'm having is that inside one of my event handlers I'm calling some DirectShow code. Inside the DirectShow code a message loop is run to handle the COM calls. Unfortunately this inner message loop pumps my input events so if I click quickly with the mouse I can get a second event handler running nested inside the first at the point of the DirectShow call. I'm not sure what the correct term is for this behaviour so I am calling it reentrant event processing (although it is not strictly rentrancy as the event handlers are likely to be different ones). The problem arises because all the event handler code assumes that it is single threaded (which it is) and that events will be processed in order from the queue. I get unpredictable crashes of my application due to this problem.
One solution I am looking at is to simply discard user input messages and timer messages while a message is being processed, hence the original topic of this thread.
Another more complicated but better solution is to run a second thread with it's own message loop and invoke the COM calls on that thread. I haven't looked into the details of this too much as yet.
I've got a simple project that demonstrates the problem which I can post if anyone would like to see it.
Thanks for your help!
regards,
Felix
|
|
|
|
|
I've had a similar issue when I try to link controls together, like a textBox and a trackBar, where updating one control should update the other. Here's how I solved it. Keep in mind this only works if it's managed code that you're trying to keep "non-reentrant".
If your code is assuming a single-threaded environment, you could try setting a lock before the DirectShow code gets called, and check that lock at the beginning of the nested events, like so:
bool lock = false;
void SomeEvent(object sender, EventArgs e)
{
if(!lock){
lock = true;
DirectShowCall();
lock = false;
}
}
void NestedEvent(object sender, EventArgs e)
{
if(!lock)
{
}
}
The lock check in SomeEvent will prevent your DirectShow code from getting called in a nested fashion.
This method isn't thread-safe. If you need thread-safety, you may want to look at Monitor.TryEnter.[^]
Dybs
|
|
|
|
|
Hi Dybs,
naturally that is a great solution if you can easily identify SomeEvent and NestedEvent, however in my case this is not so easy, there are many events that can lead to a DirectShow call and many events that could be unsafe to process nested within another call. I could search through my code and put locks in all event handlers that look likely to cause trouble but this discipline would need to be maintained in maintenance and future development, so is not ideal. The solution you propose is really a special case of my proposal to override the wndproc of all forms (by using a custom BaseForm class). The whole point of an event queue and a single gui thread is so that in programming these events one can consider them as occurring serially. Overriding message processing for the whole app will place some overhead on all activity so I'd rather avoid the wndproc solution. Another disadvantage is that by effectively discarding some messages I might see strange behaviour, for example if a user started typing while in the lock the letters entered up to the point of releasing the lock would be lost.
The alternative solution I'm going to investigate is to start a second thread with its own message loop and make all DirectShow calls synchronously on that thread. Due to good architectural choices early on in the project the references to DirectShow in my application are limited to one module so it should be easy to ensure that all calls are routed through the second thread. If it works I'll post an article here to explain the solution.
Regards,
Felix
|
|
|
|
|
|
Hi, guys
I use NATUPNPLib in order to allow my application to be reachable from Internet, although it is running on machine behind router (IGD). So I use this library to add port mapping/forwarding. But now I am kind of confused and I need help.
My first question is which IP to add in the mapping table for "local"? I've got several IPs returned by Dns.GetHostEntry(Dns.GetHostName()) for my machine, because I've got several network adapters. And I don't know which one to use for port mapping. If there is any records in the mapping table, I could examine an existing local IP from the table and I could compare it to my IPs to choose one of them. But what should I do when there aren't records?
My second question is, hypothetically, what will happen if there are more than one routers which the machine is connected to (through different adapters)? Which router will NATUPNPLib represent? Maybe all together? And in this scenario (several routers, each one connected to Internet) which adapter/router will Windows use to connect to Internet?
Best regards
|
|
|
|
|
Well, you're either going to have to write code to determine the best path to the router you want (not exactly easy), or better yet, make your app flexible and let the user decide which adapter and/or IP to use. You'd probably want to create some kind of configuration form to do this.
|
|
|
|
|
Just a matter of curiosity and general knowledge..easy question it seems but I didn't find an answer
My project (I'm using VS2008) targets .net framework 3.5, but after compiling the IDLASM shows:
// Metadata version: v2.0.50727
and examining the loaded application, the used DLLs really points to the 2.05 framework...should'nt it target the 3.5 ?
Thanks for any help
|
|
|
|
|
It is targetting 3.5. .NET 2.0, 3.0 and 3.5 all use the .NET 2.0 CLR.
.NET 3.0 and 3.5 are just set of extensions to the .NET Framework Class Libraries. Neither of them introduced any additional functionality to the .NET CLR.
|
|
|
|
|
This is the answer I thought I'd get, but I found many articles refering to this as the required framework version. So, how can I get the required framework from the assembly file ?
Thanks a lot.
|
|
|
|
|
The line you're look at is telling you the .NET CLR version that is required to execute the code, not the .NET Framework version. The CLR is the virtual machine runtime that executes the code. The Framework is the class library that supplies the functionality for the thousands of classes you can use in your code.
There is nothing in the metadata that specifies the .NET Framework version that is required to run the app. What you see in the manifest is the required .NET CLR version. Under that, you'll see a bunch of .assembly extern references. Each of these imports a namespace, specifying the public key and VERSION NUMBER the loader must bind to. Each reference can have it's own version number seperate from the rest. For example, if you create a blank WPF app targeting .NET Framework 3.5, you see the MSCORLIB is version 2.0, from .NET 2.0, SYSTEM from .NET 2.0, PresentationFramework from .NET 3.0, and WindowBase from .NET 3.0.
|
|
|
|