|
Hey.. Why do you need Regular Expression validators to prevent from SQL injection.... ??
I think it is good to have data validation in the client side... For Example :
"\d+" will only take numeric values...
You may use like
"^(Insert|Update|Delete|Select)([A-Z][a-z]+)+" [It might be better if I take time]
to ensure that the user dont enter DML statements in input.
But why do you need to do this?? I think only a simple thing solves the entire problem. Say you have a TextBox called txtName in the page, you write :
using(SqlCommand cmd = new SqlCommand("Update name = @pName where id='23'",con))
{
SqlParameter param = new SqlParameter("@pName", SqlDbType.NVarchar);
param.value = txtName.Text;
cmd.Parameters.add(param);
cmd.ExecuteNonQuery();
}
Isnt it simple enough???
|
|
|
|
|
I have one question in using validator control in ASP.net:
let's say, I have a validator bound to a textbox, just to check whether the text is empty or not.
I only want the validator checks the textbox when I click some button (such as submit), but I found that the validator also works when I do not click this button. e.g. even I try to redirect to other page, the validator still checks and I can not redirect to other page.
I am wondering, is there any property I can use to handle this problem directly except I use enable and disable functions?
thanks!!
|
|
|
|
|
Seraph_summer wrote: I am wondering, is there any property I can use to handle this problem directly except I use enable and disable functions?
Yes, That is ValidationGroup Property
In your case, Textbox , Submit button and RequiredFiledValidator Should have same ValidationGroup.
For your Referecne :
VAlidation Group[^]
Hope this will help you
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I think you can put the textbox and button in a same validationGroup .
|
|
|
|
|
thanks for both o you!
I got it!
|
|
|
|
|
Hi everybody , I have designed a web form and it has a simple Query to read data from a table .
my connection is logicaly true but I face to a error like this .
Error :
**************
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
**************
but I am sure that the server allows remote Connections .
my Connection in winform works properly .
and in design mode , before I view the webpage , Like using SqlDataSource I Can read data and make query .
please help me about this problem .

|
|
|
|
|
Does your Web Server and Database server are in same system or in different System ?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
these are in different systems.
|
|
|
|
|
This is a general problem when the Datatabase service couldnt be found.
I think the connectionstring is the culprit here. Compare the connection string with one that works in Winforms. I think there must be some mistake on it.
|
|
|
|
|
I have compared them . and also I have copyed connectionString from winform to web form but it did not work.
code is:
new SqlCommand("select [Name],MdbPath from __WorkSpace__", new SqlConnection("Data Source=Ahmadi;Initial Catalog=__Sys__;Persist Security Info=True;User ID=David;Password=500"));
|
|
|
|
|
Check like this :
SqlConnection con = new SqlConnection("Data Source=Ahmadi;Initial Catalog=__Sys__;Persist Security Info=True;User ID=David;Password=500");
con.open();
Does con.Open gives the same error ?
Also you told me that your SQL DataSource does work. Just check its connectionstring as well. Follow the steps :
Go to
View->Server Explorer
Right Click on DataConnections -> add Connection
In the dialog box :
Server Name : Ahmadi<br />
Use SqlServer Autentication, User Name = David, PAssword = 500<br />
Select Database Name : __sys__
Finally click OK.
Now when the node is created, right click on the node and go properties, and check ConnectionString . Use this connectionstring. I think it should be working fine.
|
|
|
|
|
Good Day
Can we see your connection string and show us the name of your sql instance, the name of the SQWl instance we dont mean the name of the computer. When you connect to sql query analyzer there is a part that says Server, post that name and give us the connectionstring and we will point the problem.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi , ofcourse
connectionstring is :
Data Source=Ahmadi;Initial Catalog=__Sys__;Persist Security Info=True;User ID=David;Password=500")
it works in winform properly . I have Tested it .
|
|
|
|
|
is "__Sys__" the name of your database ?
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I add webservice to my site and write a simple one.
but I can't use this webservice in another pages.
I mean that i don't know how use this service.
for example i want to use webservice on button_click Event.
|
|
|
|
|
Why on earth do you need to use your webservice from your site ? That's just pointless. I think what you may want to use is AJAX, but that's different.
You should probably explain what it is you're trying to achieve. It sounds to me like you need to read a basic book and find out what these things are for, but I could be wrong.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Ha ha ... You are right.
|
|
|
|
|
I have right click on my website in visual studio->add newitem->WebService.asmx
i write a simple translator in Service.cs
but I can't use this service in my website?
|
|
|
|
|
You didn't read my post. You CAN add a webservice, and you can probably use it, it's just a STUPID thing to do. So, the question is, WHY do you want to do this ? What do you think it will help you do ? Once you answer me that, then I can tell you how to do what you want.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I just want to learn that how can I use a websevice.asmx in my website.
|
|
|
|
|
Is your webservice is hosted in another server than your website???
If not then I think it is always better to do the task directly. Web Servers spawns a new thread to every Request made. Thus, if you are calling a web service to get Response, your Web Server will create a new thread and make a request, means an added load to the server to the request.
This way you are actually using Two threads when this could be done in a single one.
Hope you understand our concern.
|
|
|
|
|
I just want to learn thay how can I use a websevice.asmx in my website.
I right click on my website and Addwebrefrence and i browse to "Web services in this solution "
and find in URL column "service.asmx".I write "service.asmx" in URL (in address bar )but didn't accept?
what shoud i do?
I have two textbox in one of my page and user shoud fill one of them and press button.
now on cick_button Event i shoud get this text and use my webservice(my webservice is translator)to translate this word.
I should send textbox1.text to my webservice and webservice return a string that i should put it in textbox2.text;
|
|
|
|
|
The problem is that it is idiotic to use a webservice hosted on the same server. If you want to learn how to use webservices, find an external one that you can connect to. I suspect your issue is that your webservice is not running, because when you add a reference, your site is not running.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
i didn't undrestand that you said "find an external one that you can connect to"?
and what should i do for the next problem that you said?"I suspect your issue is that your webservice is not running, because when you add a reference, your site is not running"
|
|
|
|
|
I think you need to go back to reading a very basic book. I'm sorry, I can't explain it much simpler than that.
Webservices exist to provide an interface to an external client. There's plenty you can find and connect to from your site. As your website has access to your code already, there is no use in writing a webservice that connects to the same site. A webservice is not running if it's not on a live server. Your server only runs when you debug the site. So it does not exist when you try to connect to it.
You've got everything wrong and everything backwards. Start simpler. Read more. Try to understand what it is you are doing.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|