Q: URI datatype in DataSet

hi,

How can i set a constraint to a column in my dataset as URI , what i know is that dataset is XSD file, and xsd has a datatype xs:anyURI, but i didn't find this datatype in the dataset datatypes ,is there any idea

if that is not possible or not recommended how can i make constraint for textbox entery to be a valid uri or to convert the text that the user entered to uri

will be thxfull for any help




Answer this question

Q: URI datatype in DataSet

  • Johan L

    Hello shak,

    Look at this link: It offers suggestion on how to programatically add this feature to your program:

    http://www.vbaccelerator.com/home/VB/Tips/Add_File_or_URL_AutoCompletion_to_TextBoxes_and_ComboBoxes/article.asp

    Looks like this is a browser dependant feature.  This examples requires IE5 + to work.

     


  • root

     shakalama wrote:

    should i Add the http:// to the user entery by code and what about the other protocols

    I think this is a matter of preference.  Is this an off-line application   If so, then you should (my opinion) require the users to type in a VALID url before you commit to your DB. 

    What types of URL's are the users putting in this column   Will they be using other protocols   ftp://, https:// etc.

    For example, when you save a 'Favorites' in Internet explorer, or you add a shortcut on your desktop to a URL, it validates the users entry.  If you type in httz://google.com when saving a Favorite in Internet Explorer, you get an error stating:

    "The protocol "httz" does not have a registered program. Do you want to keep this target anyway "

    Maybe you could come up with some type of validation such as this.  Make your logic reasonable, but in the end, let the user decide if the url is valid.

    Hope this helps.

    Matt


  • SuriP

    Hello again shak,

    I'm not quite sure of your question.

    Are you wanting to validate that a URL scheme is valid   If so, you can use:

    Uri.CheckSchemeName Method

    Check the local help for an example of using this method.

    You can use this before (or after) you populate your column to validate the proper schema of a URL.

    Hopefully this helps,

    Matt


  • David_hary

    hi Matt

    Actualy it worked but seems there are something wrong, b4 i asked you about how to check if a page exist online or not and you direct me to webexception when i tried this it  worked with some url's and didn't' with others and i get this exception"invalid uri : the formate of the uri could not be determend"

    i guess thats because those URi's that i used doesn't have (http) protocol, as you know most of us write the uri without http and i'm sure that's what the users will do,  i can add http:// by code but there are  more than one protocol, so that i asked how to convert the user enterance to valid uri. when i used uri.checkschemename method it said the uri is valid which i know its but actualy seems i dont know what i want to do now

    here its the code with one uri without http which i always get exception from it

    Try

    Dim MyHttpWebRequest As HttpWebRequest

    MyHttpWebRequest = CType(WebRequest.Create("www.yahoo.com"

    ), HttpWebRequest)

    'Get the associated response for the above request.

    Dim MyHttpWebResponse As HttpWebResponse

    MyHttpWebResponse = CType(MyHttpWebRequest.GetResponse(), HttpWebResponse)

    MyHttpWebResponse.Close()

    Catch XX As WebException

    Dim Str As String = XX.Message

    If XX.Status = WebExceptionStatus.ProtocolError Then

    MessageBox.Show("Status Code : " & CType(XX.Response, HttpWebResponse).StatusCode & _

    vbNewLine & "Status Description : " & CType(XX.Response, HttpWebResponse).StatusDescription)

    End If

    End Try

    should i Add the http:// to the user entery by code and what about the other protocols

    hope i'll find solution for this

     



  • Andy_T

    hi, Matt

    good example that you talked about Iexplorer favorites menu, its something like that. i have more than 1000 links so it became wierd, after a while you will not remember what this link for , so i thought for sake of learning vb and do something usefull to write a program to save those links with some explanation about it, like the RSS feeds, but after a while and during updates of sites you will find among your links a broken links so i thought to add option to the program to check my links one by one and if those pages are no longer exist to give me a list with broken links and what was the error in that , so its offline program but it need to check the links online, so i need something to complete links like internet explorer address bar when you type a link not complete it complete it, try it in your internet explorer write for example www.microsoft.com it will add http:// if you write it like that microsoft.com it will add http://www. ... etc i'm sure there are something like that in vb but i'm not sure what is that



  • Tony Wu

    thx, fox

    after long time struggling with this artical i found out its for completing the uri from the history of your internet explorer and wasn't what i want, what i wanted was that something to complete the url prefx like to add http:// if it doesn't have http:// but if it has other valid protocol like ftp: it will add nothing by other word to prepare the uri to connect to it because if your uri doesn't have proper prefx during connection you will get exception, i found what i want in Uribuilder class

    Public Shared Function URIBuilder(ByVal URL As String) As Uri

    Dim instance As UriBuilder

    instance = New UriBuilder(URL)

    Return instance.Uri

    End Function

    hope it will help anyone

    thx



  • Beltira

    I think it's just a built in function for current web browsers.

    If you omit certain parts of a URL in the location field, Explorer automatically completes the entry. You can omit the following:

    • The prefix http://. Explorer automatically adds the necessary prefix to complete the URL search.

    • The partial pathname http://www.. Explorer automatically adds the necessary pathname to complete the URL search.

    • The suffix .com. Explorer automatically adds this suffix if none is specified.

  • Q: URI datatype in DataSet