|
By using Vb.Net how to get Domain name or user name
Hitesh sojitra
|
|
|
|
|
Hi Hitesh,
You may use My object to get the desired results:
My.User.Name
Best Regards,
Sam Xavier
www.componentone.com
|
|
|
|
|
|
<b>By using DirectoryEntry U can find Domain Name and then Use SchemanClassName for Getting Domain Related information </b>
Dim childEntry As DirectoryEntry
Dim ParentEntry As New DirectoryEntry()
ParentEntry.Path = "WinNT:"
Dim newNode As New TreeNode(childEntry.Name)
Select Case childEntry.SchemaClassName
Case "Domain"
txt_domainname =(childEntry.Name){ParentDomain})
Regard
Anubhava
|
|
|
|
|
Hi
I have one problem.I want to increment alphabetic(A to Z).
suppose i have one record in database as A then my next record has to save as
"B".This would be upto "Z".How to do that with minimized code?
How can i increment with A to Z?
Pls help me.
Thanks
monika
|
|
|
|
|
Hello Monika,
You may try retrieving the ascii value for the record and then increment the ascii value and
then store back the back the value after charracter conversino.
Lets Say we have 'A' as value. Its ascii value is 65.
We increment this to 66 and convert it back to 66 which will save as 'B'.
You can try the given code. In this code snippet, I am adding the values in a button click which
add A-Z on each click.
<br />
If Me.ListBox1.Items.Count = 0 Then<br />
<br />
Me.ListBox1.Items.Add("A")<br />
<br />
Else<br />
<br />
Dim ch As String<br />
<br />
ch = Me.ListBox1.Items.Item(Me.ListBox1.Items.Count - 1)<br />
<br />
Dim num As Integer<br />
<br />
num = (Asc(ch) + 1) ' Gets the Ascii value of the last chrracter and increments it.<br />
<br />
Me.ListBox1.Items.Add(ChrW(num)) ' Converts the ascii value to charracter<br />
<br />
End If
Just try implementing it. I think this should give you a hint.
Hope this helps.
Regards,
Allen
Allen Smith
Software Engineer
ComponentOne LLC
www.componentone.com
|
|
|
|
|
char x = 'A';
for (int i = 0; i < 100; i++)
{
x++;
x = x > 'Z' ? 'A' : x;
Console.WriteLine(x.ToString());
}
|
|
|
|
|
You're chating. The above is not VB code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Sometimes I've forgotten which forum that I'd wandered into...
|
|
|
|
|
appreciate if some one could help me with using InfoMessage Event of ADODB.Connection object in VB6 and SQL server.
If I pass a single SQL Print command to the ADO object, it will fire the Event and works fine, but a print command among other commands doesn't work. Am I missing something??
here is the code
Thanks
Arash
__________________________________________________________________________________________
Private WithEvents cn As ADODB.Connection
Private Sub cn_InfoMessage(ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
MsgBox pError.Description
End Sub
Private Sub Comm_UPD_Rec_Click()
SQLAdd = " DECLARE @Key int " & _
"SET @Key=(select (max(task_id)+1) from task) " & _
"insert into task (task_id,...)values (@Key ,...) " & _
" PRINT @Key"
Dim cmd As New ADODB.Command
cmd.CommandType = adCmdText
cmd.CommandText = SQLAdd
Set cmd.ActiveConnection = cn
out = cmd.Execute
End Sub
__________________________________________________________________________________________
|
|
|
|
|
Perhaps the SQL statement block is invalid?? I don't see a space between (task_id,...) and values .
This would also be better handled if it was a stored procedure in the database and not in your code.
|
|
|
|
|
The rest of the SQL statement works fine, I mean all the commands in the command do what they are supposed to do, I was expecting the PRINT or RAISERROR fire the event but they don't. And the SQL command I posted is a part of a larger SQL command that the program generates according to the condition and it's far easier to create it on the client program rather than Server.
Thanks anyway.
Arash
|
|
|
|
|
I found the Answer
the SQL command shall be enclose in a Begin...End and SET NOCOUNT ON shall be used.
so the SQL would be like
SQLAdd = " Begin SET NOCOUNT ON; DECLARE @Key int " & _
"SET @Key=(select (max(task_id)+1) from task) " & _
"insert into task (task_id,...)values (@Key ,...) " & _
" PRINT @Key; End"
I also tryed placing Select @Key at the end of the SQL command, but without Begin...End and SET NOCOUNT ON
rs.open SQLAdd will not actually open the recordset and any attempts to read the rs will result in Error Object Closed. But if you place Select @Key after the End, rs will contain the @key.
Arash
|
|
|
|
|
The main menu on my application has the minimize button available and it works good. Clicking on a button on the main menu opens up a second form. This form also has a minimize button available but when you click it it minimizes the form just above the windows task bar. Instead, I would like it to minimize itself and also the main menu form to the task bar. How can this be done?
|
|
|
|
|
I assume the first form is mdicontainer for the second form.
In second form's (mdichild) form_ClientSizeChanged-event:
If Me.WindowState = FormWindowState.Minimized Then
Me.MdiParent.WindowState = FormWindowState.Minimized
End If
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
hi all,
i need to know,when i'm coding using vb to open an autocad file how can i determine the version of the autocad that my application will be open by
thnx
|
|
|
|
|
Launching the acad drawing file itself?? You can't. It'll be opened by the version that is registered to open that particular version of the file.
You'd have to use some kind of Autocad automation library to control which version opens the file in question. I don't if this exists or not. This would be a question for AutoDesk I would think...
The only other possibility would be to buld a command line string that launches the Autocad.exe you want with the drawing file as a command line parameter. Something like:
C:\Program Files\AutoDesk\Autocad 12\AutoCad.exe "C:\some folder\folder\other folder\someDrawingFile.dwg"
All of the folders and filenames in this example are hypothetical and may not relfect actual file/folder names in the real world.
|
|
|
|
|
|
Hello
I am makeing one small application which saves and delete images in to sql database the code bellow is to load images it's works fine i can save new images to database and delete it and also moves back and forward in picture box but when i add or delete any image it does'nt shows any changes after saveing or deleting image so i have to close application and rerun it again so it shows changes i mean refresh in code bellow i have cleared dataset and then get sql connection and then fill data adapter but still it's not working
and i call this sub after save and delete image click event
any help
Private Sub LoadImages()
dsImage.Clear()
Try
conImage = GetDBConnection()
daImage.Fill(dsImage.Images)
If Me.BindingContext(dsImage.Images).Count = 0 Then
Label1.Text = "Empty Database"
Else
Label1.Text = Me.BindingContext(dsImage.Images).Count.ToString & " - Image(s) in database"
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conImage.Close()
conImage.Dispose()
End Sub
waiting for your kind rep.
have a nice day
thanks again
|
|
|
|
|
Changes you make to the database will not show up in the application unless the DataSet is refreshed. That means rerunning the query that filled the dataset in the first place.
|
|
|
|
|
Hello sir
thanks for your kind rep.
but sir i dont understand what you are trying to say so can you please tell me how to refresh data set
waiting for your kind rep.
have a nice day
|
|
|
|
|
You have to do whatever you did to fill the dataset again. I have no idea what you did to get the initial data, so I can't explain it any further than this. Whatever you did to get the initial data is what you have to do again to refresh the dataset.
|
|
|
|
|
hello sir
thanks for your rep.
this is the code i am using
and as you said that load the data in to dataset so i am loading data in loaddata sub but still i dont know what's wrong there
Private Sub LoadImages()<br />
dsImage.Clear() :confused:<br />
Try<br />
conImage = GetDBConnection()<br />
daImage.Fill(dsImage.Images) :confused:<br />
If Me.BindingContext(dsImage.Images).Count = 0 Then<br />
Label1.Text = "Empty Database"<br />
Else<br />
Label1.Text = Me.BindingContext(dsImage.Images).Count.ToString & " - Image(s) in database"<br />
End If<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
conImage.Close()<br />
conImage.Dispose()<br />
End Sub
and code for save image
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click<br />
Dim fs As FileStream = New FileStream(mImageFilePath.ToString(), FileMode.Open)<br />
Dim img As Byte() = New Byte(fs.Length) {}<br />
fs.Read(img, 0, fs.Length)<br />
fs.Close()<br />
<br />
mImageFile = Image.FromFile(mImageFilePath.ToString())<br />
Dim imgHeight As Integer = mImageFile.Height<br />
Dim imgWidth As Integer = mImageFile.Width<br />
Dim imgLength As Integer = mImageFile.PropertyItems.Length<br />
Dim imgType As String = Path.GetExtension(mImageFilePath)<br />
mImageFile = Nothing<br />
'get sql connection<br />
conImage = GetDBConnection()<br />
Dim sSQL As String = "INSERT INTO Images (Pic,Title, IType, Height, Width) VALUES(" & _<br />
"@pic, @title, @itype, @iheight, @iwidth)"<br />
commImage = New Data.SqlClient.SqlCommand(sSQL, conImage)<br />
' image content<br />
Dim pic As SqlParameter = New SqlParameter("@pic", SqlDbType.Image)<br />
pic.Value = img<br />
commImage.Parameters.Add(pic)<br />
<br />
' title<br />
Dim title As SqlParameter = New SqlParameter("@title", System.Data.SqlDbType.VarChar, 50)<br />
title.Value = txtTitle.Text.ToString()<br />
commImage.Parameters.Add(title)<br />
<br />
' type<br />
Dim itype As SqlParameter = New SqlParameter("@itype", System.Data.SqlDbType.Char, 4)<br />
itype.Value = imgType.ToString()<br />
commImage.Parameters.Add(itype)<br />
<br />
' height<br />
Dim iheight As SqlParameter = New SqlParameter("@iheight", System.Data.SqlDbType.Int)<br />
iheight.Value = imgHeight<br />
commImage.Parameters.Add(iheight)<br />
<br />
' width<br />
Dim iwidth As SqlParameter = New SqlParameter("@iwidth", System.Data.SqlDbType.Int)<br />
iwidth.Value = imgWidth<br />
commImage.Parameters.Add(iwidth)<br />
<br />
Try<br />
commImage.ExecuteNonQuery()<br />
MessageBox.Show("Image successfuly saved in database", "Image Load")<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
<br />
End Try<br />
commImage.Dispose()<br />
commImage = Nothing<br />
conImage.Close()<br />
conImage.Dispose()<br />
Call LoadImages()<br />
End Sub
any help
and i have drag and drop sqlcomand, sqladapter objects on form
waiting for your kind rep.
have a nice day
|
|
|
|
|
It's simple thing really. If you ran LoadImage in your code to setup the list before, you run it again to refresh that list and update the control.
|
|
|
|
|
hello sir
thanks for your rep.
but i think that's what i did i mean i call loadimages in form load and then i call it again after adding new image in btnSave click event and alos btnDelete click event
but not i am lost i know it's looks small thing but i can not see it
any way thank you again
|
|
|
|