Click here to Skip to main content
15,913,361 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Generalprinting to the printer with vb.net Pin
yulyos7-Aug-03 6:04
yulyos7-Aug-03 6:04 
GeneralRe: printing to the printer with vb.net Pin
pnpfriend7-Aug-03 10:21
pnpfriend7-Aug-03 10:21 
GeneralRe: printing to the printer with vb.net Pin
yulyos7-Aug-03 20:57
yulyos7-Aug-03 20:57 
GeneralRe: printing to the printer with vb.net Pin
pnpfriend8-Aug-03 5:50
pnpfriend8-Aug-03 5:50 
GeneralRe: printing to the printer with vb.net Pin
yulyos8-Aug-03 6:06
yulyos8-Aug-03 6:06 
GeneralRe: printing to the printer with vb.net Pin
pnpfriend8-Aug-03 8:48
pnpfriend8-Aug-03 8:48 
GeneralRetreving an auto number field from Access Pin
GrGonzo6-Aug-03 13:50
GrGonzo6-Aug-03 13:50 
GeneralRe: Retreving an auto number field from Access Pin
Bo Hunter7-Aug-03 14:32
Bo Hunter7-Aug-03 14:32 
This is a text app I whiped up. The Button1_Click works and Button2_Click does not.
You have to get the value before the connection is closed.

<br />
	Private m_connection As OleDb.OleDbConnection <br />
<br />
	Private m_connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source="<br />
<br />
	Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)<br />
		MyBase.OnLoad( e )<br />
		m_connectionString &= HunterDev.Environment.GetUserFolderPath( SpecialFolders.Personal ) & "\db1.mdb"<br />
	End Sub<br />
<br />
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
		If ( m_connection Is Nothing ) Then<br />
			m_connection = New OleDb.OleDbConnection( m_connectionString )<br />
		End If<br />
		Dim command As New OleDb.OleDbCommand( "INSERT INTO Sample ( Name ) VALUES ( '" & TextBox1.Text & "' )", m_connection )<br />
		Dim idCommand As New OleDb.OleDbCommand( "SELECT @@IDENTITY", m_connection )<br />
		If ( m_connection.State <> ConnectionState.Open ) Then<br />
			m_connection.Open()<br />
		End If<br />
		command.ExecuteNonQuery()<br />
		Dim id As Integer = CInt( idCommand.ExecuteScalar() )<br />
		If ( m_connection.State <> ConnectionState.Closed ) Then<br />
			m_connection.Close()<br />
		End If<br />
		TextBox2.AppendText( id.ToString() & vbCrLf )<br />
	End Sub<br />
<br />
	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click<br />
		Dim idCommand As New OleDb.OleDbCommand( "SELECT @@IDENTITY", m_connection )<br />
		If ( m_connection.State <> ConnectionState.Open ) Then<br />
			m_connection.Open()<br />
		End If<br />
		Dim id As Integer = CInt( idCommand.ExecuteScalar() )<br />
		If ( m_connection.State <> ConnectionState.Closed ) Then<br />
			m_connection.Close()<br />
		End If<br />
		TextBox2.AppendText( id.ToString() & vbCrLf )<br />
	End Sub<br />


Bo Hunter
GeneralPossible Vb Question Pin
droesch6-Aug-03 7:06
droesch6-Aug-03 7:06 
GeneralRe: Possible Vb Question Pin
RichardGrimmer18-Aug-03 4:07
RichardGrimmer18-Aug-03 4:07 
GeneralExtremly stupid VBA question Pin
Harald Krause6-Aug-03 1:17
Harald Krause6-Aug-03 1:17 
GeneralRe: Extremly stupid VBA question Pin
MrGee6-Aug-03 14:00
MrGee6-Aug-03 14:00 
GeneralRe: Extremly stupid VBA question Pin
RichardGrimmer18-Aug-03 4:08
RichardGrimmer18-Aug-03 4:08 
GeneralRe: Extremly stupid VBA question Pin
Nick Seng6-Aug-03 15:49
Nick Seng6-Aug-03 15:49 
GeneralADODB recordset Pin
_crs_6-Aug-03 0:41
_crs_6-Aug-03 0:41 
GeneralRe: ADODB recordset Pin
RichardGrimmer18-Aug-03 4:10
RichardGrimmer18-Aug-03 4:10 
GeneralVB.Net- C# integration Pin
Madhuri Mittal5-Aug-03 23:27
Madhuri Mittal5-Aug-03 23:27 
GeneralVBA help! Pin
Vladimir Georgiev5-Aug-03 23:17
Vladimir Georgiev5-Aug-03 23:17 
GeneralHardware Manipulation Pin
347Studboy5-Aug-03 13:11
347Studboy5-Aug-03 13:11 
GeneralRe: Hardware Manipulation Pin
pxw16-Aug-03 6:48
pxw16-Aug-03 6:48 
GeneralRe: Hardware Manipulation Pin
MarziehBere27-Jul-10 20:27
MarziehBere27-Jul-10 20:27 
GeneralVB events and Command Buttons Pin
blaze19785-Aug-03 12:15
blaze19785-Aug-03 12:15 
GeneralRe: VB events and Command Buttons Pin
Nick Seng5-Aug-03 16:00
Nick Seng5-Aug-03 16:00 
GeneralRe: VB events and Command Buttons Pin
blaze19786-Aug-03 3:27
blaze19786-Aug-03 3:27 
GeneralRe: VB events and Command Buttons Pin
Nick Seng6-Aug-03 15:32
Nick Seng6-Aug-03 15:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.