madsovenielsen
-
Posts
142 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by madsovenielsen
-
-
Hello I need to delete array items and compact the array (multidimentional). I have not been able to find any "build in" function for this in VBScript. I would like to be able to "delete" array items and compact the remaining items so there is no gaps. Array example:
Dim example(4,20) example(0,0) = "54HG12-KLD"example(1,0) = "Thingamabob"example(2,0) = "Good for long hikes."example(3,0) = "599" example(0,1) = "54HG12-GHJ"example(1,1) = "Thingamabob"example(2,1) = "Good for short hikes."example(3,1) = "499"...
Does anyone have a function er code snippet, or maybe some good advice on writing a function to tackle this. Kind regards Mads
-
Hello
Imports System.Web.Script.SerializationImports System.Data.SqlClientPublic Class jsonTest Dim objSQLConnection As SqlConnection Dim objSQLCommand As SqlCommand Dim objSQLDataReader As SqlDataReader Dim objJSONStringBuilder As StringBuilder Public Function returnJson() As String Dim col1 As New ArrayList Dim col2 As New ArrayList objJSONStringBuilder = New StringBuilder() Dim connString As String = System.Configuration.ConfigurationManager.ConnectionStrings("VUCConnectionString").ConnectionString objSQLConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings(connString)) objSQLCommand = New SqlCommand("select col1, col2 from table1", objSQLConnection) objSQLCommand.Connection.Open() objSQLDataReader = objSQLCommand.ExecuteReader() While objSQLDataReader.Read() col1.Add(objSQLDataReader("col1")) End While objSQLDataReader.Close() objSQLCommand.Connection.Close() Dim serializer As New JavaScriptSerializer() Dim arrayJson As String = serializer.Serialize(col1) Return arrayJson End FunctionEnd ClassPublic Class wwwroot_Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim jsontest As New jsonTest() Dim test As String = jsontest.returnJson() jsonOutput.Text = test End SubEnd Class
I am trying to return JSON data from the database, this is _so_ easy with PHP, but i am forced to use ASP.NET I am gettting the following error from the code above:
The ConnectionString property has not been initialized.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.Source Error:Line 22: objSQLCommand = New SqlCommand("select col1, col2 from table1", objSQLConnection)Line 23:Line 24: objSQLCommand.Connection.Open()Line 25: objSQLDataReader = objSQLCommand.ExecuteReader()Line 26: Source File: [url="file://\WebfilefswebsitesDATAPOOL006u12ekgqwwwrootDefault.aspx.vb"]\\Webfilefs\websites\DATAPOOL006\u12ekgq\wwwroot\Default.aspx.vb[/url] Line: 24
Everything seems fine in the editor, and i know the connection string is working, at least on other sites. Any suggestions are most welcome, and please, if there is an easier way of doing this, ala PHP, please enlighten me. Kind regards Mads Nielsen
-
Eclipse. Free. Runs on Linux And Windows. http://www.eclipse.org//madsI've always used notepad simply because I've never known of any other free one, but I'm really excited to be able to use color so its not too hard to find a piece of code.
Timetable query
in SQL
Posted · Edited by madsovenielsen
HelloI know this is a total newb question, but i have the following SQL:
This is giving me records with each weekday (Ugedag) like this:
But i need the days to be in the same record, like this:
Some sample data from the db:
Any ideas?
data.txt