First, create your project, click the project name, right-click and select the "Manage NuGet Packages" option.
Enter firesharp, select FireSharp.Serialization.JsonNet(the second one), and download.
Google search https://firebase.google.com/, click Get started >Add project, enter your customized
database name, and click create.
Click database under DEVELOPon the right side of firebase, select Realtime Database, click
Get started> Start in test mode> Enable.
Gets the linkat the top of the white box of the current page as the value of
BasePath.
In the menu bar on the right, click Project settings>Service Accounts>Database Secretsto display the Secret
of the current database as the value of AuthSecret.
Here is the code to connect to the firebase:
using FireSharp.Config;
using FireSharp.Interfaces;
using FireSharp.Response;
IFirebaseConfig config = new FirebaseConfig
{
AuthSecret = "",//Value obtained from firebase above
BasePath = "",//Value obtained from firebase above
};
IFirebaseClient client; private void Form1_Load(object sender, EventArgs e) { client = new FireSharp.FirebaseClient(config); if (client != null) { MessageBox.Show("connect is successful"); } }
You can use the following code to add, update, delete, and retrieve the data in firebase.
internal class Data
{
public string Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
public string Age { get; set; }
}
private async void button1_Click(object sender, EventArgs e)
{
var data = new Data
{
Id = textBox1.Text,
Name = textBox2.Text,
Address = textBox3.Text,
Age = textBox4.Text,
};
SetResponse response = await client.SetTaskAsync("Information/" + textBox1.Text, data);
Data result = response.ResultAs<Data>();
MessageBox.Show("Data Inserted " + result.Id);
}
private async void button2_Click(object sender, EventArgs e)
{
FirebaseResponse response = await client.GetTaskAsync("Information/" + textBox1.Text);
Data obj = response.ResultAs<Data>();
textBox1.Text = obj.Id;
textBox2.Text = obj.Name;
textBox3.Text = obj.Address;
textBox4.Text = obj.Age;
MessageBox.Show("Data Retrieved successfully");
}
private async void button3_Click(object sender, EventArgs e)
{
var data = new Data
{
Id = textBox1.Text,
Name = textBox2.Text,
Address = textBox3.Text,
Age = textBox4.Text,
};
FirebaseResponse response = await client.UpdateTaskAsync("Information/" + textBox1.Text, data);
Data result = response.ResultAs<Data>();
MessageBox.Show("Data updated at Id:" + result.Id);
}
private async void button4_Click(object sender, EventArgs e)
{
FirebaseResponse response = await client.DeleteTaskAsync("Information/" + textBox1.Text);
MessageBox.Show("Delete at Id :" + textBox1.Text);
}
private async void button5_Click(object sender, EventArgs e)
{
FirebaseResponse response = await client.DeleteTaskAsync("Information");
MessageBox.Show("All Data Delete /Information node has been deleted");
}
Here is the result of this work demo:
For more details, I suggest you learn the following videos teaching, which will teach you how to use firebase for data operation in detail.
Member
75 Points
513 Posts
how to connect sql server with firebase
Nov 25, 2019 07:57 AM|zhyanadil.it@gmail.com|LINK
i want to connect sql server with firebase it mean when inserting new row or updating row or deleting row save them in firebase how can i do it?
Contributor
3710 Points
1043 Posts
Re: how to connect sql server with firebase
Nov 26, 2019 06:45 AM|Yongqing Yu|LINK
Hi zhyanadil,
First, create your project, click the project name, right-click and select the "Manage NuGet Packages" option.
Enter firesharp, select FireSharp.Serialization.JsonNet (the second one), and download.
Google search https://firebase.google.com/, click Get started >Add project, enter your customized database name, and click create.
Click database under DEVELOP on the right side of firebase, select Realtime Database, click Get started> Start in test mode> Enable.
Gets the link at the top of the white box of the current page as the value of BasePath.
In the menu bar on the right, click Project settings>Service Accounts>Database Secrets to display the Secret of the current database as the value of AuthSecret.
Here is the code to connect to the firebase:
You can use the following code to add, update, delete, and retrieve the data in firebase.
Here is the result of this work demo:
For more details, I suggest you learn the following videos teaching, which will teach you how to use firebase for data operation in detail.
How to connect to firebase : https://www.youtube.com/watch?v=jZMwwZHJXJc
How to insert data to firebase : https://www.youtube.com/watch?v=_jB2iOgo_9Q&pbjreload=10
How to retrive data from firebase : https://www.youtube.com/watch?v=Ryrkh0wSBTE
How to update data in firebase : https://www.youtube.com/watch?v=DWyi7GH9Pgw
How to delete data in firebase: youtube.com/watch?v=cbZTx3ykEVA
Best Regards,
YongQing.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.