|
Why? Because "ImageSaveInDataBase.zip" doesn't exist on the CodeProject server?
|
|
|
|
|
No, because saving and retrieving an image from a database has absolutely nothing to do with getting the names of database filestreams.
|
|
|
|
|
No. It's not the answer because the OP is asking how to open up database filestreams.
|
|
|
|
|
|
Hello. I need a hand in my code. i wrote the following code. and i am trying to work with sql.
what should i change?
I really need some help with this :/
Public Class BindingContext
Dim _cn As New OleDb.OleDbConnection
Dim _DataAdapter As New OleDb.OleDbDataAdapter()
Dim _CommandBuilder As OleDb.OleDbCommandBuilder
Dim _DataSet As New System.Data.DataSet()
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim _provider As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
Dim _fullPath As String = "C:\Working Storage\Developments\LAB\Database Connection\Database Connection\Database\"
Dim _dataSource As String = "Data Source=" & _fullPath & "ADOnet.MDB"
_cn = New OleDb.OleDbConnection(_provider & _dataSource)
_DataAdapter.SelectCommand = New OleDb.OleDbCommand("SELECT * FROM tblCustomer", _cn)
_DataSet = New DataSet()
Try
_DataAdapter.Fill(_DataSet)
Catch eror As Exception
MsgBox(eror.Message)
End Try
cbDept.DataSource = _DataSet.Tables(0)
cbDept.DisplayMember = "Name"
cbDept.ValueMember = "ID"
Me.txtName.Text = "Sjflkjasdlk=fj"
txtName.DataBindings.Add("text", _DataSet.Tables("tblCustomer"), "Name")
txtEmail.DataBindings.Add("text", _DataSet.Tables(0), "Email")
txtAddress.DataBindings.Add("text", _DataSet.Tables(0), "Address")
cbDept.DataBindings.Add("SelectedValue", _DataSet.Tables(0), "DeptID")
End Sub
Private Sub cmdRequery_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRequery.Click
DBRequery()
Me.BindingContext(_DataSet.Tables(0)).CancelCurrentEdit()
Me.BindingContext(_DataSet.Tables(0)).Position = 0
RefreshData(True)
End Sub
Private Sub DBRequery()
cmdSave.Enabled = False
_DataSet.Clear()
Try
_DataAdapter.Fill(_DataSet)
Catch Eror As Exception
cmdAdd.Enabled = False
cmdUpdate.Enabled = False
cmdDelete.Enabled = False
MsgBox(Eror.Message, MsgBoxStyle.Exclamation, "Error Opening Database")
Close()
Exit Sub
End Try
txtCount.Text = Format(_DataSet.Tables(0).Rows.Count, "#,##0")
If _DataSet.Tables(0).Rows.Count > 0 Then
txtCurrent.Text = "1"
EnableNavigation()
End If
cmdAdd.Enabled = True
End Sub
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Try
_DataAdapter.Update(_DataSet)
Catch eror As Exception
MsgBox("This was an error updating database." & ControlChars.CrLf & _
eror.Message)
End Try
End Sub
Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
If IsNumeric(txtGoto.Text) Then
If CInt(txtGoto.Text) = CDec(txtGoto.Text) Then
If 1 <= CInt(txtGoto.Text) And CInt(txtGoto.Text) <= CInt(txtCount.Text) Then
BindingContext(_DataSet.Tables(0)).Position = CInt(txtGoto.Text) - 1
RefreshData(True)
Else
GotoError()
Exit Sub
End If
Else
GotoError()
Exit Sub
End If
Else
GotoError()
Exit Sub
End If
End Sub
Private Sub GotoError()
MsgBox("This must be an integer between 1 and " & txtCount.Text & " inclusive", MsgBoxStyle.Exclamation)
End Sub
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
Dim pDataRow As DataRow
pDataRow = _DataSet.Tables(0).NewRow()
pDataRow!name = txtName.Text
pDataRow!email = txtEmail.Text
pDataRow!Address = txtAddress.Text
_DataSet.Tables(0).Rows.Add(pDataRow)
txtCount.Text = CStr(CInt(txtCount.Text) + 1)
cmdSave.Enabled = True
txtCurrent.Text = txtCount.Text
EnableNavigation()
End Sub
Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
Dim pDataRow As DataRow
pDataRow = _DataSet.Tables(0).Rows(CInt(txtCurrent.Text) - 1)
BindingContext(_DataSet.Tables(0)).EndCurrentEdit()
pDataRow!name = txtName.Text
pDataRow!email = txtEmail.Text
pDataRow!address = txtAddress.Text
cmdSave.Enabled = True
End Sub
Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
BindingContext(_DataSet.Tables(0)).RemoveAt(BindingContext(_DataSet.Tables(0)).Position)
txtCount.Text = CStr(CInt(txtCount.Text) - 1)
RefreshData(True)
cmdSave.Enabled = True
End Sub
End Class
Thank you sooo much for your time
|
|
|
|
|
What is the problem?
Is something happening that shouldn't?
does it error? if so what is the error message?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
The code i posted works fine. But i need to use SQL instead of Access.
And i am not an expert in SQL.
So , if possible, can you tell me what to change and how in order to use SQL instead of Access?
|
|
|
|
|
I started by doing this:
imports system.data.sqlClient
Public Sub Form1
Dim _DataAdapter As New SqlDataAdapter
Dim _CommandBuilder As SqlCommandBuilder
Dim _DataSet As New DataSet
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim _cnstring As String = "Data Source=Eliane-VAIO\SQLEXPRESS;Initial catalog=ADOnet;Integrated Security=True;"
Dim _cn As New SqlConnection(_cnstring)
Dim _cmd As New SqlCommand("select * from tblCutomer", _cn)
_cn.Open()
Dim reader As SqlDataReader = _cmd.ExecuteReader()
Try
_DataAdapter.Fill(_DataSet)
Catch eror As Exception
MsgBox(eror.Message)
End Try
End Sub
But i am feeling a bit lost. And an error occurs:
the select command property has not been initialized before calling "Fill".
|
|
|
|
|
assuming you are using SQL Server I would have a read of these
ADO.NET Code examples[^]
connectionstrings[^]
but a simple example would be as follows
string Query = "select * from someTable where id = @id";
using(SqlConnection dbase = new SqlConnection("ConnectionString"))
{
dbase.Open();
SqlCommand cmd = new SqlCommand(Query, dbase);
cmd.Parameters.AddWithValue(@id, 10);
SqlDataReader rdr = cmd.ExecuteReader();
if(rdr.HasRows)
{
while(rdr.Read())
{
}
}
}
if you want to use datatables its very similar
string Query = "select * from someTable where id = @id";
DataTable dt = new DataTable();
using(SqlConnection dbase = new SqlConnection("ConnectionString"))
{
dbase.Open();
SqlCommand cmd = new SqlCommand(Query, dbase);
cmd.Parameters.AddWithValue(@id, 10);
dt.Load(cmd.ExecuteReader());
}
hope this helps you start to convert your rountine to work with SQL Server
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Thank you for your help. I am new to SQL
I am trying to assemble the code. It's a bit hard for me, since it's my first time with SQL.
If you can assemble the code for me I will be more than thankfull
Thanks again.
|
|
|
|
|
I am afraid to say that I wont write your code for as how would you learn if I did it for you. I have given links to examples on the web that will help you learn what you are after doing.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Yes i saw the links. now i'm reading their content
and i am trying to figure it out. Thank you ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Thank you for your help. I am new to SQL
I am trying to assemble the code. It's a bit hard for me, since it's my first time with SQL.
If you can assemble the code for me I will be more than thankfull
Thanks again.
|
|
|
|
|
Nobody is going to do your work for you. We all have our own code to write.
The conversion from Access to SQL is rather simple. Wherever you have "OleDb..." you replace with "Sql". That includes OleDbConnection, ...Command, DataReader, ...
|
|
|
|
|
Guys I have made a editor with richtextbox.After entering text and while saving,it is saved as ".txt" but how to save it in "rtf" format.
Plz Help me it is saved only as ".txt" and not as ".rtf".
|
|
|
|
|
Without seeing the code you're using to "save", it's impossible to tell you what you did wrong.
|
|
|
|
|
Which property of the RTB did you read? There's two that might be used; one that returns plain text, one[^] that returns the text with RTF encoding.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
plz.. help me. how to host win form appl in web. i read some blogs,first convert win form application to wpf. then host that wpf in iis.
if it's the process how to convert .
|
|
|
|
|
Kindly don't repost your question across multiple forums.
|
|
|
|
|
can we work .net4.0, visual studio 2010,mysql 5.6 with tomcat7.0
.is it possible to work tomcat server with .net
|
|
|
|
|
It is possible using a project called Mono - not directly.
|
|
|
|
|
|
Hello Every Respected Engineers.
I am working of a Billing Software. My Question is that:
I have a Challan and ChallanDetails Table. To show ChallanDetails ( list of product and rate etc) for a Challan, I have used a bound datagridview in which these columns are there
SrNo
ProductID
Qty
Rate
Amount
now when I show any existing challan, I have used datagridview's CellFormatting Event to show name of the Product instead of its ID. This works perfectly fine
My problem is that while making new challan entry, I have to type the ProductID (which is hard to remember). I want that when user types the name of the product, it should store its ProductID and show ProductName in that column. But when I type the name of product and press enter, I get the system error message of invalid format because it is a Numeric column and wont allow text.
Please give me suggestion how can I do this.
Thanks in advance
Dinesh Prajapati
Dinesh
|
|
|
|
|
I am sorry to have to state the obvious, but you need to change the column type so it will accept the product name.
Veni, vidi, abiit domum
|
|
|
|
|
Thanks for your quick response
But Sir, the dgv is bound to a bindingsource and the column is integer type. I tried a lot but couldnt find any option to change the type of datagridvew column to text. and i dont want to change the database column itself.
Thanks
Dinesh
|
|
|
|