|
|
Thanks for the link will download the source and read it through it.
|
|
|
|
|
I am very new for VB.net (Visual Studio 2005) and also very new for SQL Server 2005 Express
I do have a Trial1.mdf install in Server Local c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Trial1.mdf
I tried to connect/open/close as the following codes:
<br />
Imports System.Data.SqlClient<br />
<br />
Public Class Form1<br />
<br />
Dim sqlConnection As New SqlConnection("server=localhost;uid=NULL;pwd=NULL;database= c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Trial1.mdf")<br />
<br />
sqlConnection.Open()<br />
sqlConnection.Close() <br />
End Class<br />
But it fail to run (even re-build no-error), can someone tell me what should I do to use my Trial1.mdf correctly?
Thanks for any help
|
|
|
|
|
Hi
For connecting to database, you need to provide UID, password and database. The .MDF file can be attached to the SQL Server.
For attaching the database, Check this link
Attaching Database[^]
After attaching, your database name will be the datasource in your connection string.
Hope this helps.
Harini
|
|
|
|
|
I did try as you said and it improves my issue, however I still can not open and use my trial1.mdf. Here my update codes:
<br />
Imports System.Data.SqlClient<br />
<br />
Public Class Form1<br />
'Link database<br />
Dim DB_Location = "c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Trial1.mdf"<br />
Dim MyConnection = "Server=localhost; DataBase= " & DB_Location & "Integrated Security=SSPI"<br />
Dim sqlConnection As New SqlConnection(MyConnection)<br />
<br />
'Use database<br />
Dim strSQL As String = "SELECT FROM Trial1 WHERE col2 = 'trial' "<br />
Dim cmd As New SqlCommand(strSQL, MyConnection)<br />
<br />
sqlConnection.Open() ' ----> error<br />
cmd.ExecuteNonQuery() ' ----> error<br />
sqlConnection.Close() ' ----> error<br />
<br />
End Class<br />
At the last 3 line of codes I got the errors ... can you help me to correct it?
Thanks
|
|
|
|
|
I wrote a screen saver using the starter kit that came with VB 2005 Express. Worked great! Then I wanted it to kick off an application when it ended, thus:
.
.
'Code here validates a password
.
.
Process.Start("AppPath", "Params")
Thread.Sleep(2000)
Close()
With the screensaver active, I move the mouse. It asks for the secret word. I type the word. The application pops up. Two seconds later the screen saver and the application die together.
When I run the screen saver from the command line it works the way I want it to.
What do I have to do to make it work that way in screen saver mode?
JimT
|
|
|
|
|
Doesnt Windows control the activation/de-activation of screensavers? You probably have to dive deeper into the Windows APIs in order to control that behavior.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
The screen saver problem turns out to be one of ownership. If the operating system starts the screen saver because of inactivity, it is owned by the system, and it, along with everything it owns, goes in the dumper when some activity causes it to close. If you start it from the command line, or by clicking on it in Windows Explorer, or by clicking the preview button, you own it and it acts just like any other program; if it starts a child process, the child continues after the parent dies.
The problem, then, is to convince the OS that the child process does not belong to its parent. This is done by setting the UserName and Password parameters in the StartInfo structure before starting the child process. The only difficulty is that StartInfo.Password is not a System.String but a Security.SecureString, that is, it’s encrypted, so it takes a little doing to create it.
|
|
|
|
|
Did you just reply to yourself with the answer?
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
I was so desperate I was forced to think about it.
|
|
|
|
|
Well good job, now if I ever have the issue, Ill just refer to your reply to yourself.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
right now i'm trying to add data to a database. i think i'm almost their but get this error message
"Property access must assign to the property or use its value"
this is what code i got
Imports System.Data.OleDb
Public Class Cust
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim icount As Integer
Dim str As String
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\PCBank.mdb;")
cn.Open()
str = "insert into customer values(" & CInt(tbID.Text) & ",'" & tbSur.Text & "','" &
tbFor.Text & "')"
'string stores the command and CInt is used to convert number to string
cmd = New OleDbCommand(str, cn)
icount = cmd.ExecuteNonQuery
MessageBox.Show(icount)
'displays number of records inserted
Catch
End Try
cn.Close()
End Sub
End Class
can anybody enliten me?
|
|
|
|
|
I might have the answer you seek, but I haven't looked in any depth at this problem. It may be something to do with the insert statement and/or the customer table. Does the table only have 3 columns: an id, a surname and a forename? Is the id column auto-generated (or whatever the term is in MS Access)? Try naming the columns in your insert statement. I don't know what columns your customer table has but it might be something like this: insert into customer (id, surname, forename) values (99, 'Rogers', 'Dave') Dave
|
|
|
|
|
Hello!
It is quite bit intrique because I am creating 80 buttons in runtime and assigning a name with an incremental value such as myButton.Name = "GButton_" + I.toString. Therefore, each button has a different name.
Dim I as Int32
For I = 1 to 5
Dim myButton as New Button
myButton.Name = "GButton_" + I.toString
me.controls.add(myButton)
Next
How can I reach the GButton_3.backcolor property somewhere in code (out of the procedure where I create the buttons). Would it be possible to define the name and set its property? Is there a way to use such as EVAL function to perform something eval( "GButton_" + I.tostring + ".backcolor=" + setcolor) THANK YOU.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Why throw away the reference to the button that you actually have, and then try to get it again?
Just store the references in an array so that you easily can access the buttons later.
---
single minded; short sighted; long gone;
|
|
|
|
|
hi,
it is easier as you think
either you iterate the "Controls" collection of the Form:
For Each ctl as Control In Me.Controls
If ctl.Name = "GButton2" Then
ctl.Backcolor ....
Exit For
End If
Next
or you just call the following:
Me.Controls("GButton2").Basckcolor ...
storing it in an array is not necessary, because the added controls are already stored in an collection (Me.Controls)
solidIT.de - under construction
Components for Microsoft .Net
audittrail, objectcomparer, deepcopy and much more ...
|
|
|
|
|
Thank you! I will try it...
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
testy_proconsul wrote: it is easier as you think
It's even easier than you think.
testy_proconsul wrote: storing it in an array is not necessary, because the added controls are already stored in an collection (Me.Controls)
Yes, of course it's not necessary, but it's the easiest and fastest way to get the reference.
---
single minded; short sighted; long gone;
|
|
|
|
|
"i dont wanted to cut you short" ... guffa. and sorry for my bad english
but opinion is to keep the overhead as small as possible and to use predefined functionality. generally this keeps overview, readability and conformity ...
solidIT.de - under construction
Components for Microsoft .Net
audittrail, objectcomparer, deepcopy and much more ...
|
|
|
|
|
Can anyone help me or point me in the right direction.
I am running VB.Net 2003 and have a form that I wish to print. For argument's sake, the form has 4 fields e.g. txtField1.text, txtField2.text, txtField3.text and txtField4.text
Each field has a value in it. How can I print this form or fields direct to my printer. The reason I want to do it this way is that each field has a complex calcualation to get to its value. Another way is how could I make a text file with these values and put onto a crystal report.
I hope this make sense.
|
|
|
|
|
You might be able to use this control[^], although it is written in VB.Net 2005 so you may have to do some changes...?
|
|
|
|
|
Hello!
In shown sample below, I have a loop what ceates instances of a button. What I want to know is which one gets clicked in runtime? Thank you.
<code>
Public Sub AddButtons()
For I = 1 to 10
Dim myButton as new Button
myButton.text = "Hello"
me.Controls.Add(myButton)
AddHandler myButton.click, AddressOf myButtonEvent
Next
End Sub
' Here is the event handler for the button
Private sub myButtonEvent (Byval Sender as Object, e as EventArg)
'Here I want to know which button has been clicked because there are 10
'buttons on the form.
End Sub
</code>
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
in your button event:
dim b as Button<br />
b= Ctype(sender,Button)
the b will be the button that was clicked.
If you are wanting to run different code depending on what button was clicked you can check for the name, or assign a value to the tag property and use that for identification.
Hope that helps
-- modified at 11:34 Tuesday 13th March, 2007
|
|
|
|
|
Yep! it is working now. Thank you very much.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
You would want to set the button id value.
Something like myButton.Id = "btn"+I.ToString();
Then in the event
CType(Sender, Button).Id to figure out which button.
Hope that helps.
Ben
|
|
|
|