|
sathesh_pandian wrote: while reader.read
And how does this limit it to one record being returned from the database?
sathesh_pandian wrote: if reader(0)=UserName and reader(1)=PassWord Then
Very poor technique.
only two letters away from being an asset
|
|
|
|
|
Have you considered using the asp.net membership stuff? There are login controls that you can use. There is a sql script that needs to be run that will create all of the tables stored procedures etc. in your sql database. I think it would make a lot of sense to use something that works verses trying to write it your self. You could also use the Profile object to store stuff you might normally store in a cookie.
I know you said you don't want links, but you have to start somewhere:
http://msdn2.microsoft.com/en-us/library/yh26yfzy.aspx[^]
This one is one profile:
http://msdn2.microsoft.com/en-us/library/d8b58y5d.aspx[^]
Ben
|
|
|
|
|
As kubben replied uisng the builtin membership provider stuff is easy and will take care of this problem.
However if you need to authenticate against a custome database then just check the number of records returned.
DataTable dt = Authenticate(username, password);<br />
if( dt.rows.count > 1 )<br />
return false;<br />
else<br />
return true;
only two letters away from being an asset
|
|
|
|
|
Hi,
I have a datatable filled with data I get from a sql query and database. Has the following columns in:
EmployeeID
EmployeeName
EmployeeSurname
EmployeeSickLeaveDate
I just want to select all the data from column "EmployeeName" in the datatable. By that, I only want to populate a new datatable with "EmployeeName"
How will this be possible. I tried using datatable.select(), but no luck, or I am not using it correct.
|
|
|
|
|
I would try this:
I am assuming you are using vb.net
Dim dt DataTable = firstDataTable.Clone()
'This removes EmployeeID
dt.Columns.RemoveAt(0)
'This removes EmployeeSurname
dt.Columns.RemoveAt(1)
'This removes EmployeeSickLeaveDate
dt.Columns.RemoveAt(1)
So now you have a new dataTable with only one column.
Hope that helps.
Ben
|
|
|
|
|
Thank you Ben,
I think this method will help me a lot. Will try it over the weekend.
Regards
Playout
|
|
|
|
|
Provided of course that the ordinal of the columns doesn't change.
This is a bit brute force and not really necessary.
only two letters away from being an asset
|
|
|
|
|
First way would be to have the database query return only the column you are looking for.
Otherwise try this
DataTable EmployeeName = new DataTable();<br />
EmployeeName.Columns.Add("EmployeeName");<br />
EmployeeName.Merge(fullDataTable);
only two letters away from being an asset
|
|
|
|
|
Hi everybody.
Currently i'm developing a system in Visual Basic .NET under 1.1 Framework, that requires add a couple of webcontrols (mainly Buttons), and i need these controls to respond to events, like the Click one. Is very easy to do this to a control added to a project on design time. But if i want to add buttons on execution time, and that every button responds to a click doing something (something simple like raise a javascript message, or delete a database record) i get confused.
I tried using Button.Attributes.Add("onclick", "something-to-do") but this approach is not working at all.
I really apreciate if someone knows how to do this.
Kind regards,
Leistath.
"I hated myself... no, I hated my place in the world" - From Jerry Maguire
|
|
|
|
|
In vb.net use
<br />
'After you create your control<br />
AddHandler Button1.Click, AddressOf Button1_Click<br />
<br />
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) <br />
<br />
'put your code here, it should fire on postback<br />
End Sub
I didn't get any requirements for the signature
|
|
|
|
|
Thank you ToddHileHoffer. I followed your suggestion and i get working this now. I really appreciate your help mate.
Regards,
leistath
"I hated myself... no, I hated my place in the world" - From Jerry Maguire
|
|
|
|
|
hi,
its Asp.net discussion forum. i think you are trying to use the asp.net method in the
vb.net.
you have to add some handlers for this.
eg.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AddHandler Me.Click, AddressOf form_click
End Sub
Sub form_click(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
This handler will be called when the form has been clicked.
Try this type and you can remove it
through
removehandler Me.Click, AddressOf form_click
All The Best
Sathesh Pandian
|
|
|
|
|
Thanks Sathesh, i've understood how this works. Thank you so much.
"My pain is constant and sharp...and i do not hope for better world for anyone. In fact, i want my pain to be inflicted on others..." - Children Of Bodom - Bodom Beach Terror
|
|
|
|
|
Hi all,
Some time before I was struggling with Page break. now I found the method for page break nad still finding to add columns headers after 15 rows.
I am using the following script to set up the page break after printing 15 items in a page. It is working all right. Is there any other way to insert page break after certain page margin?
protected void GVMaterialMovement_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
count++;
if(count > 15)
{
e.Row.Style.Add("page-break-after", "always");
count = 0;
}
}
}
Is there any similar way to add header after each 15 Records?
Bajrang Singh
Using .net 2.0 (VS2005)
|
|
|
|
|
Hi there.
I am uploading images to my website and them writeing it into a DB. I want to do validation on the image that i upload. At the moment i am checking the size(bytes) of the image. what i also need to do, is check the Physical lenght of the image.
Can anyone help me with this?
Thanks
|
|
|
|
|
if(fileUpload1.HasFile == true)
{
blah blah...
}
Hope it helps
|
|
|
|
|
Try this.
<br />
<script runat="server"><br />
Sub submit(Sender as Object, e as EventArgs)<br />
fname.InnerHtml=MyFile.PostedFile.FileName<br />
clength.InnerHtml=MyFile.PostedFile.ContentLength<br />
End Sub<br />
</script><br />
<br />
<html><br />
<body><br />
<br />
<form id="Form1" method="post"<br />
enctype="multipart/form-data" runat="server"><br />
<p><br />
Select file to upload to server:<br />
<input id="MyFile" type="file" size="40" runat="server"> <br />
</p><br />
<p><br />
<input id="Submit1" type="submit" value="Upload!" OnServerclick="submit"<br />
runat="server"><br />
</p><br />
<p><br />
<div id="Div1" runat="server"><br />
FileName: <span id="fname" runat="server"/><br /><br />
ContentLength: <span id="clength" runat="server"/> bytes<br />
</div><br />
</p><br />
</form><br />
<br />
</body><br />
</html> <br />
<br />
Bajrang Singh
Using .net 2.0 (VS2005)
|
|
|
|
|
Can any one please tell me how to display messagebox on a button click using a server control.
Thanks in advance
|
|
|
|
|
Use Javascript to Display the Message Box
Regards,
Satips.
|
|
|
|
|
<script language="javascript" type="text/javascript">
function confirmation()
{
return window.confirm("Are sure u want to redirect");
}
</script>
If (Not Page.IsPostBack) Then
Button1.Attributes.Add("onclick", "javascript:return confirmation();")
End If
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("archana.aspx")
End Sub
Sonia Gupta
Soniagupta1@yahoo.co.in
|
|
|
|
|
I am not sure what programming language and what version of .net you are looking for. Here is an example in vb.net for .net 1.1
Private Sub ShowMessageBox(ByVal aMessage As String)
'This procedure will cause a dialog box to pop up with whatever message is passed in.
aMessage = aMessage.Replace(vbCrLf, "\n").Replace("""", "'")
Dim myScript As New StringBuilder
With myScript
.Append("<script>")
.Append(Environment.NewLine)
.Append("alert(""").Append(aMessage).Append(""");")
.Append(Environment.NewLine)
.Append("</script>")
Page.RegisterStartupScript("Promo Error", .ToString())
End With
End Sub
It is slightly different for .net 2.0 and the syntax is a little different for C#.
Hope that helps.
Ben
|
|
|
|
|
Thanks for all ur Replies. I will check your suggestions,
Im using dotnet2005 i.e version2.0 and vb.net as codebehind
|
|
|
|
|
In that case the code is slightly different:
Private Sub ShowMessageBox(ByVal aMessage As String)
'This procedure will cause a dialog box to pop up with whatever message is passed in.
aMessage = aMessage.Replace(vbCrLf, "\n").Replace("""", "'")
Dim myScript As New StringBuilder
With myScript
.Append("<script>")
.Append(Environment.NewLine)
.Append("alert(""").Append(aMessage).Append(""");")
.Append(Environment.NewLine)
.Append("</script>")
ClientScript.RegisterStartupScript(Me.GetType(), "Promo Error", .ToString())
End With
End Sub
Ben
|
|
|
|
|
is there any event that fires up when the web for is closed?
Sonia Gupta
Soniagupta1@yahoo.co.in
|
|
|
|
|