|
You'd be better off asking this in the ASP.NET Forum.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ok, I posted the question there too
|
|
|
|
|
vb.net:
using excel-file as database. usual using access-database, but in this case i want to fill data from a datagrid into a excel-sheet.
connection to excel-file and displaying its data in a datagrid works fine, but when i want to update it (see comment in code below), i get an error. i am updating my access-database the same way, never experienced problems there. please help.
<br />
<br />
Private conn As String <br />
Private DBCon As OleDbConnection<br />
Private DBDat As OleDbDataAdapter<br />
Private DBCom As OleDbCommandBuilder<br />
Private DatT As DataTable<br />
Private BMB As BindingManagerBase<br />
<br />
<br />
button1_click:<br />
conn = "Provider= Microsoft.Jet.OLEDB.4.0; Data Source=" & Environment.CurrentDirectory & "\test.xls; Extended Properties=Excel 8.0;" <br />
Dim SQLString As String = "SELECT * FROM [sheet1$]" <br />
DBCon = New OleDbConnection(conn) <br />
DBDat = New OleDbDataAdapter(SQLString, DBCon) <br />
DBCom = New OleDbCommandBuilder(DBDat) <br />
DatT = New DataTable<br />
<br />
DBCon.Open()<br />
DBDat.Fill(DatT) <br />
DBCon.Close()<br />
<br />
BMB = Me.BindingContext(DatT)<br />
<br />
DataGrid1.DataSource = DatT<br />
<br />
TextBox1.DataBindings.Clear() <br />
TextBox1.DataBindings.Add("text", DatT, "F1") <br />
<br />
<br />
button2_click: 'here i want ot update my excel-sheet<br />
<br />
bmb.AddNew()<br />
TextBox1.Text = "test" <br />
bmb.EndCurrentEdit()<br />
<br />
'everything fine till here, but next line causes trouble:<br />
DBDat.Update(DatT)<br />
|
|
|
|
|
Without knowing what the error is, it's impossible to give you any kind of accurate advise.
But, the one GLARING problem you have is using the Environment.CurrentDirectory property to build a path. The current directory can change at any time and cannot be used reliably to specify the path to a file. Use Application.StartupPath instead. This will return the path to your .EXE file that was launched, every time. So, the code to build your path to the .XLS file might look something like this:
Dim connString As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;", _
Path.Combine(Application.StartupPath, "test.xls"))
Now, I don't do any Office interop or work with Excel files, but it might also be true that the TEST.XLS file must exist FIRST before you try to connect to it with your code.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
the excel-file does already exist in my bin-directory and there is no problem connecting to that file and displaying its content in a datagrid.
also i don't think, that there's a problem with the "environment.currentdirectory"-part, since there was no change during loading the excel-sheet and trying to update it and it worls fine with access that way.
but i will try this. Thanks.
|
|
|
|
|
klappklapp wrote: since there was no change during loading the excel-sheet and trying to update it and it worls fine with access that way.
In your test environment, that's true. Out in the the "real world", that doesn't hold true. Unless you have special reason to do so, NEVER use CurrentDirectory as you don't have complete control over what the current directory is at any time.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Folks,
I want to encrypt a text box such that when someone enters there password - it does not show only '*' for each character entered.
Is there property?
What is an easy what to do this?
CiscoKid55
|
|
|
|
|
And what do you wanto to show, instead?
Crypted password?
I'm not sure, but this is not one of best practices (maybe unsafe...)
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.
|
|
|
|
|
When someone enters their password -
Password: George
I would want the screen to show
Password: ******
This would prevent anyone that happened to walk up from seeing their password.
Thanks for you help
CiscoKid55
|
|
|
|
|
Sorry, that wasn't clear to me...
The property is:
Password (TextBox class, VB.NET).
PasswordChar (TextBox control, VB6).
see MSDN for further details.
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.
|
|
|
|
|
Thanks - that was what I needed.
Have a great day!
CiscoKid55
|
|
|
|
|
|
Use a stored procedure and have it find you the max value of the primary key column and add 1 to it and then insert the record using the new value.
Declare @NextID int;
Select @NextID=(case when Max(ID) is null then 1 else Max(ID)+1 end) From Table1
Insert Into Tablel (TStamp,ID,...) values (GetDate(),@NextID,...)
|
|
|
|
|
Is it possible to have eg 8 threads in a Blocking status waiting for a multicasts from 8 different feeds.
Whats the best way of doing this. i have 8 different senders of UDP packet and i need to know when ech is transmitted and from what machine its coming from
|
|
|
|
|
1) setup 8 different listeners on 8 different ports. then there is no confusion on who's sending you the packet because each sender is assigned to his/her own port.
2) setup 1 listener and in the packet have some identifier of who's doing the sending or resolve the sender's ip address to know who it is.
i would opt for #2 unless there is a lot of traffic coming from each sender but obviously your call...
Nathan
|
|
|
|
|
Sounds good. but
1) Is it possible to have all 8 broadcasting on the same port?
2) Is it possible to get the IP address of the sender by reading the header of the UDP?
|
|
|
|
|
1) (hopefully I understand your question) yes each sender can send a packet to your program using the same port (1 listener) at the same time. there maybe some queuing involved but as along as the transaction isn't long, there will be notice of any delay.
2) the socket itself should give you the ip address of the sender. i believe there is an ariticle or 2 within codeproject.com that will give an example.
|
|
|
|
|
Hi - Would like to disable this option in my Windows Installer project - how would we go about doing this?
Thanks for your time.
|
|
|
|
|
One more time this day !
I would like to find the equivalent of ReadXml under CF1.0 for CF2.0.
Thank you,
Ch'Portos.
Yop Yop !!
|
|
|
|
|
sorry i dont get any seperate section for VB
i have a problem related to vb.
i have developed an application thru vb and sql-server.
when i m using it frm my pc it works fine
but frm client pc it does not connect to database.
error on this line....
conn.open()
on client pc sql-server client utility is installed
wht to do..
i m very much confused
reply ASAP..
Ajay
|
|
|
|
|
What is your connection string? Are you using a DSN or DSN-Less connection?
BLee
|
|
|
|
|
my connection string is
Constr = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password=;Initial Catalog=TestCapex;Data Source=192.168.41.2"
m using DSN-Less connection.
plz help
i m very upset..
|
|
|
|
|
192.168... is an internal IP address. Make sure you use the correct IP address if your client is outside of your local network.
Jonathan Sampson
www.SampsonResume.com
|
|
|
|
|
ya my client is in our local network..
and one thing which shd be noticed here is that
i m getting access frm my PC
but not frm my client's PC..
now i have given public access to the database.
any suggetion
|
|
|
|
|
Unless the IP you gave us is fake, the 192.168 is a "safe" ip address used internally for networks. can the user's PC get to that IP address? ping it from the user's pc to check.
|
|
|
|