lcfjoertoft Light Poster

Is it posible to create IPAD or Android applications on my PC using VB.NET?

If so, any good advice where to start my reading on the topic?
If not, what language are best suited for the task?

lcfjoertoft Light Poster

Hi all

I have "borrowed" a function from the net, and need som help in modifying it to do what I want.

[CODE]
Public Function CrossTab(ByVal dtS As DataTable, ByVal leftColumn As String, ByVal topField As String, ByVal dataValue As String, Optional ByVal pFix As String = "") As DataTable
If dtS Is Nothing Then
Return Nothing
End If

    Dim dtOut As New DataTable
    Dim dtRowTitle As New DataTable
    Dim dtColHeader As New DataTable

    dtRowTitle = dtS.DefaultView.ToTable(True, dtS.Columns(leftColumn).ColumnName)
    dtColHeader = dtS.DefaultView.ToTable(True, dtS.Columns(topField).ColumnName)

    Dim dColx As New DataColumn
    dColx.ColumnName = leftColumn
    dColx.Caption = leftColumn
    dtOut.Columns.Add(dColx)

    For Each drow As DataRow In dtColHeader.Rows
        Dim dCol As New DataColumn
        dCol.ColumnName = pFix & drow.Item(topField).ToString.Trim
        dtOut.Columns.Add(dCol)
    Next

    Dim drowx As DataRow
    For Each drow As DataRow In dtRowTitle.Rows
        drowx = dtOut.NewRow()
        drowx.Item(0) = drow.Item(leftColumn)
        dtOut.Rows.Add(drowx)
    Next

    Dim xVal As Int32 = 0
    Dim yVal As Int32 = 0

    For Each mRow As DataRow In dtS.Rows
        Dim xRowVal As String = mRow.Item(leftColumn).ToString
        Dim dataVal As String = mRow.Item(dataValue).ToString
        Dim yColVal As String = mRow.Item(topField).ToString.Trim

        For Each nRow As DataRow In dtOut.Rows
            If xRowVal = nRow.Item(0).ToString Then
                For xVal = 0 To nRow.Table.Columns.Count() - 1
                    If nRow.Table.Columns(xVal).ColumnName = pFix & yColVal Then
                        Dim rIndex As Int32 = dtOut.Rows.IndexOf(nRow)
                        dtOut.Rows(rIndex).Item(xVal) = dataVal
                        Exit For
                    End If
                Next
                Exit For
            End If
        Next
    Next

    dtOut.DefaultView.Sort = dtOut.Columns(0).ColumnName
    DataGridView1.DataSource = dtOut
    Return dtOut

End Function

[/CODE]

On row 10 (in the above code) I need to pass more than just one column. I need to pass inn 5 columns. ...

lcfjoertoft Light Poster

First I tried getting a SQL query into an array, and then mail it. Made the data incomprehendable. So someone told me to use CSS to build a table format, filling it with the array. A LOT of hard work (since I had to learn css all the way from "what is a css".
Then I was told "Array? why use array when DATATABLES are soooo much easier"

So here we go again. "What is a datatable, and how does it work"

Now finally nailed it and am ready to place my nice and sorted datatable into the body of the mail.

Now "everyone" tells me that the best way to put the datatable into the mail is to read the datatable into a STRING !?! and past it into the mail body!!!

Am I back to sqare one?

I want to move my DataGridView1 from form1 into my mail.
How do I do that?

lcfjoertoft Light Poster

I'm creating a small program to read from an SQL server, loading result into an array, pivoting the array to my liking and mailing it out to selected members of a group.

It's going to be run once a day with Windows schedule.

I have the connection, query and mail sorted, but not the datareader to array bit. Anyone know how it's done (line 26)?

[CODE]
Imports System.Data
Imports System.Data.SqlClient
Imports System.Net.Mail

Module Module1
Sub Main()
'Connection to SQL
Dim con As New SqlConnection
con.ConnectionString = "Data Source=localhost\SQLEXPRESS;Initial Catalog=db;integrated security=SSIP;Persist Security Info=False;Trusted_Connection=Yes"
con.Open()

    'Query SQL
    Dim cmd As New SqlCommand("SELECT DISTINCT REG,K.NAME,L.LOCATION,L.LOCATION_NAME,A.INSTRUCTION, " & _
         "SUM(CASE SAMPLE WHEN 'POS' THEN 1 WHEN 'OK' THEN 1 ELSE 0 END) AS Pos,COUNT(CODE) as 'Sum' " & _
            "FROM PT_SAMPLE P " & _
            "INNER JOIN PT_SAMPLE_PARTS PP ON P.SAMPLE = PP.SAMPLE " & _
            "INNER JOIN KT_CUSTOMER K ON P.CUSTOMER = K.CUSTOMER " & _
            "INNER JOIN LT_LOCATION L ON L.LOCATION = P.LOCATION " & _
            "INNER JOIN AT_CODE A ON A.CODE = PP.CODE " & _
            "WHERE DATE LIKE '20111104%' AND CODE <> 'NA' AND CODE NOT LIKE 'PREVIOUS%' AND P.ZT <> 'W' " & _
            "GROUP BY REG,K.NAME,L.LOCATIONL,L.LOCATION_NAME,CODE,A.INSTRUCTION", con)
    Dim reader As SqlDataReader = cmd.ExecuteReader()
    con.Close()

    'Convert to array
    ?

    'Mail setup
    Dim mMailMessage As New MailMessage()
    mMailMessage.From = New MailAddress("Sender")
    mMailMessage.To.Add(New MailAddress("Reciever"))
    mMailMessage.Subject = "Subject"

    'CSS setup for presentation of array (work in progress)
    Dim Body As String
    Body = "<!DOCTYPE html PUBLIC " & Chr(34) & "-//W3C//DTD XHTML ...

lcfjoertoft

Yes, that will work.
Thanks

lcfjoertoft Light Poster

I've extracted some data from an SQL server, put it into an array, and want to mail it's content to a group of people.
All quite easy, until it comes to presentation in the mail body.

When I set it up manually in Excel and do Copy - Paste it looks readable. How do I create a 2D "worksheet" that I can put into the mail body so it looks ok?

(I'm quite a n00b at this, so there are surely some premade functions for this, If so, just point me in the right direction)

lcfjoertoft Light Poster

Hi all.

I have a problem that I haven't found a solution for on the web, so maybe anyone here can assist.

Om our server at work we use excel, but it always starts in "Excel wasn't started correctly last session. Do you want to start in safe mode", wich messes up my scripted automated excel files, since they can't answer "no".

Does anyone know how to disable this function?
I have the ActiveX Safty Mode switched off.
Excel is installed for several users.

lcfjoertoft

Pivot? Didn't know that. I'm mainly using [url]www.w3schools.com[/url]. Says nothing about pivot or case. I guess I have to broaden my search a bit.

Thanks for the reply tho :)

lcfjoertoft

@adam k: Perfect! Didn't know about case statements. Opend up a new world!

A follow up question.

Lets say I want to increase my query to contain SAMPLEID, and I want to move the analysis from the Y-axis to the X-axis giving something like this:

SampleID | One | Two | Three
a | 30 | 25 | 30
b | 10 | 0 | 0
c | 50 | 50 | 5

The analysis can also contain 'Four' but is not displayed because there are no value asociated with 'Four'.

lcfjoertoft Light Poster

Hi all.

I am trying to create a search that displays 3 columns.
Analysis, Amount, Amount of Positiv results

I have nailed down Analysis, Amount, but have problems displaying Pos. result.

[CODE]
SELECT DISTINCT SP.ANALYSIS AS Analysis,COUNT(SP.ANALYSIS) AS Amount
FROM SAMPLE S
INNER JOIN SAMPLE_PARTS SP ON SP.SAMPLEID = S.SAMPLEID
WHERE S.SAMPLE = '18000'
GROUP BY SP.ANALYSIS
[/CODE]

This gives the folowing:
Analysis | Amount
One | 30
Two | 25
Three | 30

Lets say 10 of each has the value 'POS' in the the column SP.RESULT. How would I then get a 3.rd column in my result displaying the amount of 'POS' reslts?

lcfjoertoft

Thanks bitbit. It wasn't installert. Didn't know it had to be, but Thanks to you, It's fixed.

lcfjoertoft Light Poster

I have the following connection string in a Excel VBA project:

oCon.ConnectionString = "Driver={SQL Native Client};Server=SQL;Database=D1; Trusted_Connection=yes;"

On my laptop this works perfectly. But when I try it out on another computer I get an error:

I get this error when oCon.Open on debugging:

Run-time error '-2147467259(80004005)':
Automation error
Unspecified error

On first time run i get the error:

Run-time error '-2147467259(80004005)':
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified

What is wrong?
(Posted it here since it is vb code)

lcfjoertoft

Got it working, but wil read up on JOIN to maybe improve the code.

"SELECT T1.Date,T3.Result FROM T1,T2,T3 WHERE T1.Location_ID = T2.Location_ID AND T1.ID = T3.ID AND T2.Location = '" & Value & "'"

1st and 2nd comparison after WHERE Links the table.
3rd sets the condition.

lcfjoertoft Light Poster

I am having difficulty with a SQL query in my project.

I have 3 tables.

T1:

  • Date
  • ID
  • Location_ID

T2:

  • Location
  • Location_ID

T3:

  • ID
  • Result

From this I need the T1.Date and T3.Result based on Location in T2.

So my I need a query to compare a known location, get the Location_ID. Then Use that Location_ID to get the Date and ID. Use the ID to get the Result from T3. (Value is a variable with the known Location)

This is what I have tried:
[CODE]
"SELECT T1.Date,T3.Result
FROM T1,T2,T3

WHERE T1.Location_ID = (SELECT T2.Location_ID FROM T2 WHERE T2.Location = '" & Value & "') AND T3.ID = (SELECT T1.ID FROM T1 WHERE T1.Location_ID = (SELECT T2.Location_ID FROM T2 WHERE T2.Location = '" & Value & "'))"
[/CODE]

I get the error 'Sub query returns more than 1 value...'
What am I doing wrong?

lcfjoertoft Light Poster

I'm creating a search function for my program, and need some help with SQL. Until now I have been using simple SQL query like
[CODE]
"SELECT post1 FROW table1 WHERE a=b"
[/CODE]
and put it into arrays. Then using that info to do another query, put it into arrays, and so on.

I know there are ways to improve my SQL querys like this
[CODE]
"SELECT table1.post1, table2.post2 FROM table1, table2 WHERE a=b"
[/CODE]
(more or less)

I want to query (using JOIN?) 3 tables, where some of the posts are only intermediate data to find posts in other tables.

Table 1:
UserName
UserID

Table 2:
Date
UserID
CustomerID

Table 3:
Order
CustomerID

Result:
Date,Order

I have the UserName, and from that I need to get the UserID to get to the latest Date and corresponding CustomerID. Then use the CustomerID to get the Order.
All UserName has 3 UserID (Only one are in use at any given time).
All Dates has between 1 and 500 CustomerID
All CustomerID has 1 Order

lcfjoertoft

Another example to show the result i want to create.

[url]http://www.thelogofactory.com/logo_blog/index.php/creating-3d-spinning-logo-animation/[/url]

(The spinning logo near the bottom)

Is this beyond the skills of daniweb?

lcfjoertoft

A small Youtube flic showing a spinning logo the way I need it to.
[url]http://www.youtube.com/watch?v=1i8oHaFADaI&feature=related[/url]

The Image size is 1.5 x 1 in.

The Image is a .tif (can be converted)

The goal is to program it in vb.net, not insert a 3rd party app.

lcfjoertoft Light Poster

I want to make a small logo in the upper corner of a Form rotate.

I've seen on some forums that they have small avatars dancing and such, so I imagine it would be posible to make a tiny image rotate by it self up in the corner in a Form.

Does anyone know how to do this?
Link to tutorial, codesnippets etc..

Ps. The goal is to make it smooth. Not turn 4 x 90 degrees.

lcfjoertoft Light Poster

I'm using Visual Studios 2008 to write a small program that writes to a file.

The program works fine until I run it on my server at work, where for some reason it adds a "next line" (like vbCrLf command) at the end of the second line in the .txt file.

Looks like three squeres:
"Location =□□□"

A copy paste of the string from textfile is shown under:
"Location =

"

Excerpt from program:

[CODE]
If saveFileDialog1.ShowDialog() = DialogResult.OK Then
myStream = saveFileDialog1.OpenFile()
If (myStream IsNot Nothing) Then
Using sw As System.IO.StreamWriter = New System.IO.StreamWriter(myStream)
For Lagre = 0 To UBound(RunNr) - 1
sw.Write(RunNr(Lagre) & vbCrLf)
Next
End Using
myStream.Close()
Me.Close()
End If
End If
[/CODE]

The content of the resulting .txt file:

Date & time = 22 mar 2011
Location =□□□
File Name = 1.txt
One
Two
Three
Four

lcfjoertoft

No.
Nailed it a couple of hours ago, and haven't gotten around to update thread.

Btw. Left() doesn't work. Have to use:
[CODE]
Array(Integer).Substring(Start as Integer, Length as Integer)
[/CODE]

Solution to OP:

Had to DirectCast it.

[CODE]
Dim RB as RadioButton
RB = DirectCast(Me.Controls(Array(Integer).Substring(1,3)), RadioButton)
RB.Checked = True
[/CODE]

Run it in a loop for each post in file, and put code for handeling each button in turn.

Thankyou for reply tho Jx_Man :)

lcfjoertoft Light Poster

I have a grid of RadioButtons, and need some help in Check / Uncheck acording to data collected from a .txt file.

The .txt file contains a list like this:
A01,a
B01,b
C01,c
A02,a
B02,b
C02,c

I have set up in a grid formation RadioButtons, and named them A01,B01,C01,A02,B02,C02.
I have loaded the .txt file in an array, and want to use the first 3 letters in the array to point to the RadioButton.

Problem:
How do I get the string "A01" from the array to point to the RadioButton control?

lcfjoertoft Light Poster

I have loaded a .TXT file into an array, and want to display each of the posts in the array in a grid.

Any pointers how to start attacking this beast?
Have tried using Datagrid, and failed :(
I have a "Learn by doing" approach to VB.NET, so I need a little help with the doing part :)

Attachment shows my idea of how it should look:
13x9 grid setup.

lcfjoertoft Light Poster

I'm trying to bind an Array to a DataGrid using VB.NET (2008), and I get an error. Array was not one-dimentional array. Any pointers?

[CODE]
DataGridView1.DataSource = arrProv

[/CODE]

Size of array: arrProv(4,21)

lcfjoertoft

Sweet! Since I'm only going to read, and be in and out in a flash, this will not be a problem. Thankyou lolafuertes for the help.

lcfjoertoft

My plan is to import the data in arrays, and sort out the posts for various tasks and displayed. Then loop it ever so often to update the information.

So I was hoping that the code that I have written would not interfer with other programs reading and writing to the database. Sort of opening the db file for reading without confiscating the use for other programs.

lcfjoertoft Light Poster

I've managed to put together some code to retrieve data from a sql file. I plan to connect to a sql server that are operated by a database program, that update the registry every 10 sec.

Before I try to connect my program to the sql database, I need to know if my program will prohibit other progrograms to read and write to the database.

Anyone see any problems?

My program:

[CODE]

Imports System.Data.SqlClient

Public Class Form1

Dim SQLRead As SqlDataReader
Dim connStr As String = "Server=.\SQLExpress;AttachDbFileName=C:\tmp\DB\MyDB.mdf;integrated security=true;database=MyDB"
Dim sqlcon As New SqlConnection(connStr)
Dim QueryString As String

Private Sub Parts()

    QueryString = "SELECT DATE, PCRID, STAT, PROVNR, CODE FROM dbo.PARTS"
    Dim PartsCmd As New SqlCommand(QueryString, sqlcon)
    sqlcon.Open()

    SQLRead = PartsCmd.ExecuteReader()

    While SQLRead.Read()
        'Some Code

    End While

    SQLRead.Close()
    sqlcon.Close()

End Sub

Private Sub Prov()
    QueryString = "SELECT LOT, ART, ANATYPE, RUN, PROVNR dbo.PROV"
    Dim ProvCmd As New SqlCommand(QueryString, sqlcon)
    sqlcon.Open()

    SQLRead = ProvCmd.ExecuteReader()

    While SQLRead.Read()
        'Some Code
    End While

    SQLRead.Close()
    sqlcon.Close()

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

End Class

[/CODE]