|
ciacia wrote: is is possible to edit the code of .aspx file while running the application?
Yes. If you have the relevant file permissions you can alter an ASPX file. However, it isn't wise to permit that level of access as it would remove some of the protection set up to prevent websites from being attacked.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
can you please tell me how do I achive it? I am surrently debugging my code so every time loading the page takes lot of time . Also I have one more question to ask... I want to execute sql statement to compare two dates on my web page with the one in the database
strsql = "select * from emp where My_date >= " & FDAte & " and Mydate >= " & TDate
where Fdate and Tdate are strings containing valid date.I tried using ' and also #
|
|
|
|
|
ciacia wrote: can you please tell me how do I achive it?
It is very unwise. It also opens your application to more security concerns. Things that ASP.NET and IIS would have taken care off for you but you now have to handle yourself.
ciacia wrote: I want to execute sql statement to compare two dates on my web page with the one in the database
strsql = "select * from emp where My_date >= " & FDAte & " and Mydate >= " & TDate
where Fdate and Tdate are strings containing valid date.I tried using ' and also #
And this question shows that you don't have a sufficient understanding of security. Any guidance that I could give on your problem in the space of a forum post wouldn't be enough to protect you from yourself.
You might want to read up on security before you go much further with this project.
The first thing to read is about SQL Injection attacks and you are vulnerable to that right now. See SQL Injection Attacks and tips on how to prevent them[^]
I'm sorry this doesn't answer your question, but there are other things you really need to learn first, in my opinion.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Hi CodeProject Team,
Can anyone help me to understand +/- of both? I know people usually say go for the language where you have more skill set, background etc... But i need to understand more capablity(technical) of each others...
So anmyone?
Amit
|
|
|
|
|
What ever one you favour - They are so close it really make no significant difference.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
I'll second Colin's answer above....
In the pre- .NET days there was a big differnece, but now all the .NET languages reference the same classes/framework, and (unlike before) VB too is (or can be) properly compiled (it used to be psuedo-compiled and then that was dealt with on the run; the so-called Just-In-Time compiler.)
So the differences are much less relevant now in .NET, and for the majority of "everyday" applications it really is a matter of personal choice which you prefer to use. I would suggest that unless your understanding pf programming is such that you already know the answer to your question, then you aren't likely to be programming anything that makes one language a technically better choice than another. So go for the one you prefer.
There is no doubt that VB is an easier language to learn. Many C# programmers equate that with being simplistic itself, which is a somewhat simplistic argument.... make no mistake: VB.NET is an extremely powerful language.
|
|
|
|
|
Yes we all are correct.
http://blogs.msdn.com/csharpfaq/archive/2004/03/11/87816.aspx
http://blogs.msdn.com/csharpfaq/archive/2004/03/11/87816.aspx
|
|
|
|
|
I think the C# Development Team is making better advances than the VBN Team is doing in the next Framework update.
I should probably say "innovation", not "advances". It would be wise to look at the planned updates in the new Framework.
|
|
|
|
|
If you're starting out, C# is better as VB is poorly designed and full of hidden traps. If you know VB already, you will know how to negotiate those traps, and the others are right, it makes no real difference
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I know I can access, for example, the title tag directly via Page.Header ... but can I access certain tags specifically, the way you can in CSS/Javascript, similar to getElementByID?
So if you ask why not just use getElementById, it's because I need to modify the actual HTML so the spiders read the my modified changes.... also I need to get a collection of all the tags of a certain type, without knowing the exact ID names ie, get all the H3 tags and prepend the text inside those tags with a variable...
ie
<h5 class="header"> Paragraph</h5> to<br />
<h5 class="header">myvariablename Paragraph</h5><br />
<br />
can this be done?<br />
-- modified at 13:44 Friday 20th July, 2007
|
|
|
|
|
Hi
I was wondering if anyone knows how to write a method
Which will extract all the values set in an mySQL enum field and populate them into a drop down box
e.g.
order_placed | enum('Yes','No')
i would want my drop down box to be populated with the values yes/no
cheers
boyinde
|
|
|
|
|
As far as I am aware, the only way to retrieve enum values is like this:
SHOW COLUMNS FROM table_name LIKE 'enum_column_name'
This would return a data set like this:
column 0: enumColumn (the column name)
column 1: enum('yes','no') (the enum values)
column 2: yes or no, dependong on whether NULL is allowed
...other stuff
So you would need to read the SQL call into a datareader, or something, extract extract column 1 (ie the second column) and parse the value to get what ytou want- then write these to a dataset and bind that to your drowpdown...
Oh what fun!
|
|
|
|
|
sounds like a lot of borin work lol
is it possible to hardcode the values into the <asp:dropdownlist> tag?
|
|
|
|
|
What do you mean? You can hard-code dropdown values, of course....
|
|
|
|
|
Well the values that i am extracting would only be a yes/no
could i hard code these in and pass them into my enum field?
|
|
|
|
|
well of course:
<asp:DropdownList runat="server" id="ddlYesNo">
<asp:ListItem value="Yes">Yes</asp:listItem>
<asp:ListItem value="No">No</asp:listItem>
</asp:DropdownList>
Then just read the postback value and update the database as usual...
|
|
|
|
|
wot a tube forgettin bout list item
would i need to cast them to an enum value or is a string acceptable?
|
|
|
|
|
it's just a string (in your case) - eg:
update table_name set enum_column_name = 'yes'
|
|
|
|
|
Do you know if its possible to rewrite the following code for a textbox in a datagrid to a drop down list
<asp:TextBox runat="server" ID="txtUpdate" Text='<%#convert.tostring(databinder.eval(container.dataitem,"groups")) %>'></asp:TextBox>
<EditItemTemplate>
<asp:DropDownList runat=server id="listUpdate">
<asp:ListItem Value="Admin">Admin</asp:ListItem>
<asp:ListItem Value ="User" >User</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
i don't know where i can set the databinder field, so that i can send it to my update statement
|
|
|
|
|
You need to bind it in the ItemDataBound avent of the databgrid.
if your table has a column called "AccessLevel" with (enum?) values "Admin" or "User", then you could use something like the below in this (ItemDataBound) event:
If e.Item.ItemType = ListItemType.EditItem Then
Dim lstUpdate As ListBox = e.Item.FindControl("lstUpdate")
Dim dr As DataRow = e.Item.DataItem.Row, DataRowView
lstUpdate.Items.FindByValue(dr("AccessLevel")).Selected = True
End If
|
|
|
|
|
Previous posty is how you set it, of course, to the value it already has. You read it back and updaate the database in the UpdateCommand event of the datagrid, using:
Dim SelectedID As String = datGridID.DataKeys(e.Item.ItemIndex).ToString
to get teh row ID of teh row in question
Dim lstUpdate As DropdownList = e.Item.FindControl("lstUpdate")
to get the dropdown, then buidl your sql statemetn by it's SelectedValue property
(just realised I used Listbox in earlier post, not DropdownList so you'll need ot amend that)
|
|
|
|
|
HI Fred
I still can't get this bit of code to work
I have this so far
If e.Item.ItemType = ListItemType.EditItem Then
Dim lstUpdate As DropDownList = e.Item.FindControl("lstUpdate")
Dim dr As DataRow = e.Item.DataItem.row
lstUpdate.Items.FindByValue(dr("groups")).Selected = True
End If
I get this error message for "dim dr As DataRow = e.Item.DataItem.row"
Object variable or With block variable not set
You have said to put it as datagridview, but it doesn't seem to like that I am guessin it should be my datagrid variable that goes in here and it still doesn't work
|
|
|
|
|
hm.. we could probably run round forever on this - if you want to email your complete page (html and code-behind) I'll have a look at it for you... blank out your db connectionstring (esp if it's on a public server)
|
|
|
|
|
Heres my code here fred
<code>
Public Sub onEdit(ByVal source As Object, ByVal e As DataGridCommandEventArgs) Handles dgPriv.EditCommand
dgPriv.EditItemIndex = e.Item.ItemIndex
bindGrid()
End Sub
Public Sub oncancel(ByVal source As Object, ByVal e As DataGridCommandEventArgs) Handles dgPriv.CancelCommand
dgPriv.EditItemIndex = -1
bindGrid()
End Sub
Public Sub onUpdate(ByVal source As Object, ByVal e As DataGridCommandEventArgs) Handles dgPriv.UpdateCommand
Dim err As New LiteralControl
If e.Item.ItemType = ListItemType.EditItem Then
Dim lstUpdate As DropDownList = e.Item.FindControl("lstUpdate")
Dim dr As DataRow = e.Item.DataItem
lstUpdate.Items.FindByValue(dr("groups")).Selected = True
End If
Dim SelectedID As String = dgPriv.DataKeys(e.Item.ItemIndex).ToString
Try
Dim cnString As String = "Server=;"
Dim cn As New MySqlConnection(cnString)
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection, so can pass SQL query
cmdString.Connection = cn
'Set command string to equal SPROC
cmdString.CommandText = "sp_update"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim param As MySqlParameter
param = cmdString.Parameters.Add("?p_userid", MySqlDbType.Int64)
param.Direction = ParameterDirection.Input
param.Value = dgPriv.DataKeys(e.Item.ItemIndex)
param = cmdString.Parameters.Add("?p_groups", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = SelectedID
cn.Open()
cmdString.ExecuteNonQuery()
cn.Close()
Catch ex As Exception
err.Text = ex.Message
MsgBox(ex.Message)
End Try
dgPriv.EditItemIndex = -1
bindGrid()
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:datagrid id="dgPriv" runat="server" BorderWidth="0"
CellPadding="4" Width="100%"
Font-Size="Smaller"
HeaderStyle-HorizontalAlign="Center"
HeaderStyle-Font-Bold="True"
HeaderStyle-BackColor="Navy"
HeaderStyle-ForeColor="White"
datakeyfield ="userId"
AlternatingItemStyle-BackColor="ActiveBorder"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False" >
<Columns>
<asp:BoundColumn DataField ="userId" HeaderText="User ID" ReadOnly="true"></asp:BoundColumn>
<asp:BoundColumn DataField ="username" HeaderText="User Name" ReadOnly="true"></asp:BoundColumn>
<asp:BoundColumn DataField ="groups" HeaderText="Privelages" ReadOnly="true"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Update Privelages">
<EditItemTemplate>
<asp:DropDownList runat=server id="listUpdate" DataMember='<%#convert.tostring(databinder.eval(container.dataitem,"groups")) %>' >
<asp:ListItem Value="Admin">Admin</asp:ListItem>
<asp:ListItem Value ="User" >User</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn ButtonType="PushButton" EditText="Change Privelage" UpdateText="Change" CancelText ="cancel" >
</asp:EditCommandColumn>
</Columns>
<PagerStyle HorizontalAlign="Left" />
<AlternatingItemStyle BackColor="ActiveBorder" />
<HeaderStyle BackColor="Navy" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
</asp:datagrid>></code>
|
|
|
|
|
hmm well I assume you've missed bits out... anyway, the immediate thing is that you ned to bind the lstUpdate control in the itemdatabounbd event - it's too late and no good trying to do it in the update event.
But in a way that's not vital - it just sets the dropdown to the value it already has in the database - useful but not critical.
For the update, all you need do is find the dropdown control and use it's selectedValue property...
btw, why are all your Sub's public?
Anyway, here is some amended bits
Private Sub dgPriv_ItemDataBound(ByVal source As Object, ByVal e As DataGridItemEventArgs) Handles dgPriv.ItemDataBound
If e.Item.ItemType = ListItemType.EditItem Then
Dim lstUpdate As DropDownList = e.Item.FindControl("lstUpdate")
Dim dr As DataRow = e.Item.DataItem
lstUpdate.Items.FindByValue(dr("groups")).Selected = True
End If
End If
Public Sub onUpdate(ByVal source As Object, ByVal e As DataGridCommandEventArgs) Handles dgPriv.UpdateCommand)
Dim err As New LiteralControl
' Dim SelectedID As Integer = dgPriv.DataKeys(e.Item.ItemIndex)
Dim lstUpdate As DropDownList = e.Item.FindControl("lstUpdate")
Try
' code here cut for space; you will nned to put it back!
Dim param As MySqlParameter
param = cmdString.Parameters.Add("?p_userid", MySqlDbType.Int64)
param.Direction = ParameterDirection.Input
param.Value = dgPriv.DataKeys(e.Item.ItemIndex) ' = SelectedID
param = cmdString.Parameters.Add("?p_groups", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = lstUpdate.SelectedValue
cn.Open()
cmdString.ExecuteNonQuery()
cn.Close()
Catch ex As Exception
err.Text = ex.Message
MsgBox(ex.Message)
End Try
dgPriv.EditItemIndex = -1
bindGrid()
End Sub
|
|
|
|