|
Thanks for the reply.
Here is the code:
con = connect()
con.Open()
'transaction begins here-------
trans = con.BeginTransaction()
Try
'Data is inserted into mastertable---------
cmd = New SqlClient.SqlCommand("INSERT INTO mastertable(mbno,mbdate,mbamount,mbcperson) VALUES(" & counter_bill_no & ",'" & server_date & "'," & billvalue & "," & countercode & ")", con, trans)
cmd.ExecuteNonQuery()
cmd = New SqlClient.SqlCommand("select mbid from mastertable WHERE mbno=" & counter_bill_no & " and mbcperson=" & countercode & " ", con, trans)
mb_id = cmd.ExecuteScalar
'Data inserted into detailtable-----------
i = 0
For i = 0 To row_no - 1
selling_rate = DataGridView1.Item(2, i).Value
If selling_rate <> 0 Then
cmd = New SqlClient.SqlCommand("INSERT INTO detailtable(dbno,dbdate,dbicode,biquantity,dbamount) VALUES(" & mb_id & ",'" & server_date & "'," & DataGridView1.Item(4, i).Value & "," & DataGridView1.Item(1, i).Value & "," & DataGridView1.Item(3, i).Value & ")", con, trans)
cmd.ExecuteNonQuery()
End If
Next i
'Data commited--------
trans.Commit()
Catch ex As Exception
trans.Rollback()
MsgBox("Bill could not be generated, Please try again.")
End Try
con.Close()
|
|
|
|
|
Hi, I would like to get into a listbox all the field names from my access DB.
eg: fields ID, Name, Phone....
I have open a connection, created a dataset called Mydatatable and added data into a datagridview.
mydatatable = ds.Tables("test")
mydatagrid.DataSource = mydatatable
Then i've used LbListDB.DataSource = mydatagrid.Columns but here i get something not really nice like name + index...
I just want to get the name.
How can I do?? I suppose I have to use something like LbListDB.ValueMember= ??
Thx Tchouny
|
|
|
|
|
You Can use secondory style
after open the connection with the Data base you can insert data One by one
While Rs.Read = true
listbox.items.add Rs.Reader("ABC");
end while
Anubhava Dimri
919250168195
|
|
|
|
|
hi,
use following statements
For i As Integer = 0 To mydatatable.Columns.Count - 1<br />
LbListDB.items.add(mydatatable.Columns(i).ColumnName)<br />
Next
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
It works fine. Thx a lot.
|
|
|
|
|
I want to display and select multiple related data in one control.
i will have to update the selected data in database again.
can anyone suggest me what control to use on form.?? with code
|
|
|
|
|
You Can Use Data Grid For This Action.
Anubhava Dimri
anubhava.prodata@gmail.com
9250168195
|
|
|
|
|
If you're using .NET 2.0 or above, the DataGridView control is better than the (now deprecated, if not, it should be) DataGrid control.
|
|
|
|
|
|
You got the answer to this question earlier today.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
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)
|
|
|
|